-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from GEOS-ESM/develop
Merge Develop into Main for release
- Loading branch information
Showing
12 changed files
with
275 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"license": "other-open", | ||
"upload_type": "software", | ||
"creators": [ | ||
{ | ||
"name": "Thompson, Matthew", | ||
"affiliation": "GMAO SSAI", | ||
"orcid": "0000-0001-6222-6863" | ||
}, | ||
{ | ||
"name": "Chakraborty, Purnendu" | ||
}, | ||
{ | ||
"name": "Clune, Tom", | ||
"affiliation": "NASA", | ||
"orcid": "0000-0003-3320-0204" | ||
} | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Thompson, Matthew", | ||
"affiliation": "GMAO SSAI", | ||
"orcid": "0000-0001-6222-6863", | ||
"type": "ContactPerson" | ||
}, | ||
{ | ||
"name": "Clune, Tom", | ||
"affiliation": "NASA", | ||
"orcid": "0000-0003-3320-0204", | ||
"type": "ProjectLeader" | ||
} | ||
], | ||
"keywords": [ | ||
"git", | ||
"repository", | ||
"python", | ||
"yaml" | ||
], | ||
"access_right": "open" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import argparse | ||
|
||
class MepoTagArgParser(object): | ||
|
||
def __init__(self, tag): | ||
self.tag = tag.add_subparsers() | ||
self.tag.title = 'mepo tag sub-commands' | ||
self.tag.dest = 'mepo_tag_cmd' | ||
self.tag.required = True | ||
self.__list() | ||
self.__create() | ||
self.__delete() | ||
|
||
def __list(self): | ||
tglist = self.tag.add_parser( | ||
'list', | ||
description = 'List tags.' | ||
'If no component is specified, runs over all components') | ||
tglist.add_argument( | ||
'comp_name', | ||
metavar = 'comp-name', | ||
nargs = '*', | ||
help = 'Component to list tags in') | ||
|
||
def __create(self): | ||
create = self.tag.add_parser( | ||
'create', | ||
description = 'Create tag <tag-name> in component <comp-name>') | ||
create.add_argument('tag_name', metavar = 'tag-name') | ||
create.add_argument( | ||
'-a', '--annotate', | ||
action = 'store_true', | ||
help = "Make an annotated tag") | ||
create.add_argument( | ||
'-m', '--message', | ||
type=str, | ||
metavar = 'message', | ||
default = None, | ||
help = "Message for the tag" | ||
) | ||
create.add_argument( | ||
'comp_name', | ||
metavar = 'comp-name', | ||
nargs = '+', | ||
help = 'Component to create tags in') | ||
|
||
def __delete(self): | ||
delete = self.tag.add_parser( | ||
'delete', | ||
description = 'Delete tag <tag-name> in component <comp-name>') | ||
delete.add_argument('tag_name', metavar = 'tag-name') | ||
delete.add_argument( | ||
'comp_name', | ||
metavar = 'comp-name', | ||
nargs = '+', | ||
help = 'Component to delete tags in') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
from state.state import MepoState | ||
from utilities import verify | ||
from repository.git import GitRepository | ||
|
||
def run(args): | ||
allcomps = MepoState.read_state() | ||
max_namelen = len(max([x.name for x in allcomps], key=len)) | ||
comps2list = _get_comps_to_list(args.comp_name, allcomps) | ||
max_namelen = len(max([x.name for x in comps2list], key=len)) | ||
FMT = '{:<%s.%ss} | {:<s}' % (max_namelen, max_namelen) | ||
for comp in allcomps: | ||
for comp in comps2list: | ||
git = GitRepository(comp.remote, comp.local) | ||
output = git.list_branch(args.all).rstrip().split('\n') | ||
print(FMT.format(comp.name, output[0])) | ||
for line in output[1:]: | ||
print(FMT.format('', line)) | ||
|
||
def _get_comps_to_list(specified_comps, allcomps): | ||
comps_to_list = allcomps | ||
if specified_comps: | ||
verify.valid_components(specified_comps, allcomps) | ||
comps_to_list = [x for x in allcomps if x.name in specified_comps] | ||
return comps_to_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from state.state import MepoState | ||
from utilities import verify | ||
from repository.git import GitRepository | ||
|
||
# Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 | ||
import os, tempfile, subprocess | ||
|
||
def run(args): | ||
allcomps = MepoState.read_state() | ||
verify.valid_components(args.comp_name, allcomps) | ||
comps2crttg = [x for x in allcomps if x.name in args.comp_name] | ||
|
||
tf_file = None | ||
|
||
if args.annotate: | ||
create_annotated_tag = True | ||
elif args.message: | ||
create_annotated_tag = True | ||
else: | ||
create_annotated_tag = False | ||
|
||
if create_annotated_tag: | ||
# Pop up an editor if a message is not provided | ||
if not args.message: | ||
EDITOR = git_var('GIT_EDITOR') | ||
initial_message = b"" # set up the file | ||
|
||
# Use delete=False to keep the file around as we send the file name to git commit -F | ||
tf = tempfile.NamedTemporaryFile(delete=False) | ||
tf_file = tf.name | ||
tf.write(initial_message) | ||
tf.flush() | ||
subprocess.call([EDITOR, tf.name]) | ||
|
||
for comp in comps2crttg: | ||
git = GitRepository(comp.remote, comp.local) | ||
git.create_tag(args.tag_name,create_annotated_tag,args.message,tf_file) | ||
print('+ {}: {}'.format(comp.name, args.tag_name)) | ||
|
||
if create_annotated_tag: | ||
# Now close and by-hand delete the temp file | ||
if not args.message: | ||
tf.close() | ||
os.unlink(tf.name) | ||
|
||
def git_var(what): | ||
''' | ||
return GIT_EDITOR or GIT_PAGER, for instance | ||
Found at https://stackoverflow.com/a/44174750/1876449 | ||
''' | ||
proc = subprocess.Popen(['git', 'var', what], shell=False, | ||
stdout=subprocess.PIPE) | ||
output = proc.stdout.read() | ||
status = proc.wait() | ||
if status != 0: | ||
raise Exception("git_var failed with [%]" % what) | ||
output = output.rstrip(b'\n') | ||
output = output.decode('utf8', errors='ignore') # or similar for py3k | ||
return output | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from state.state import MepoState | ||
from utilities import verify | ||
from repository.git import GitRepository | ||
|
||
def run(args): | ||
allcomps = MepoState.read_state() | ||
verify.valid_components(args.comp_name, allcomps) | ||
comps2deltg = [x for x in allcomps if x.name in args.comp_name] | ||
for comp in comps2deltg: | ||
git = GitRepository(comp.remote, comp.local) | ||
git.delete_tag(args.tag_name) | ||
print('- {}: {}'.format(comp.name, args.tag_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import subprocess as sp | ||
|
||
from state.state import MepoState | ||
|
||
from command.tag.tglist import tglist | ||
from command.tag.create import create | ||
from command.tag.delete import delete | ||
|
||
def run(args): | ||
d = { | ||
'list': tglist, | ||
'create': create, | ||
'delete': delete | ||
} | ||
d[args.mepo_tag_cmd].run(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from state.state import MepoState | ||
from utilities import verify | ||
from repository.git import GitRepository | ||
|
||
def run(args): | ||
allcomps = MepoState.read_state() | ||
comps2list = _get_comps_to_list(args.comp_name, allcomps) | ||
max_namelen = len(max([x.name for x in comps2list], key=len)) | ||
FMT = '{:<%s.%ss} | {:<s}' % (max_namelen, max_namelen) | ||
for comp in comps2list: | ||
git = GitRepository(comp.remote, comp.local) | ||
output = git.list_tags().rstrip().split('\n') | ||
print(FMT.format(comp.name, output[0])) | ||
for line in output[1:]: | ||
print(FMT.format('', line)) | ||
|
||
def _get_comps_to_list(specified_comps, allcomps): | ||
comps_to_list = allcomps | ||
if specified_comps: | ||
verify.valid_components(specified_comps, allcomps) | ||
comps_to_list = [x for x in allcomps if x.name in specified_comps] | ||
return comps_to_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters