Skip to content

Commit

Permalink
add gita group -p option to modify group path #187 (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosarthur authored Sep 6, 2021
1 parent 156d177 commit dcb74c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
23 changes: 16 additions & 7 deletions gita/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def _path_name(name: str) -> str:
"""
Return absolute path without trailing /
"""
return os.path.abspath(name).rstrip(os.path.sep)
if name:
return os.path.abspath(name).rstrip(os.path.sep)
return ''


def f_add(args: argparse.Namespace):
Expand Down Expand Up @@ -236,15 +238,19 @@ def f_group(args: argparse.Namespace):
elif cmd == 'add':
gname = args.gname
if gname in groups:
# TODO: update group path as well
gname_repos = set(groups[gname]['repos'])
gname_repos.update(args.to_group)
groups[gname]['repos'] = sorted(gname_repos)
if 'gpath' in args:
groups[gname]['path'] = args.gpath
utils.write_to_groups_file(groups, 'w')
else:
# TODO: update group path as well
gpath = ''
if 'gpath' in args:
gpath = args.gpath
utils.write_to_groups_file(
{gname: {'repos': sorted(args.to_group), 'path': ''}},
{gname: {'repos': sorted(args.to_group),
'path': gpath}},
'a+')
elif cmd == 'rmrepo':
gname = args.gname
Expand Down Expand Up @@ -585,8 +591,12 @@ def main(argv=None):
dest='gname',
type=partial(_group_name, exclude_old_names=False),
metavar='group-name',
required=True,
help="group name")
required=True)
pg_add.add_argument('-p', '--path',
dest='gpath',
type=_path_name,
metavar='group-path')

pg_rmrepo = group_cmds.add_parser('rmrepo', description='remove repo(s) from a group.')
pg_rmrepo.add_argument('to_rm',
nargs='+',
Expand Down Expand Up @@ -679,6 +689,5 @@ def main(argv=None):
else:
p.print_help() # pragma: no cover


if __name__ == '__main__':
main() # pragma: no cover
1 change: 0 additions & 1 deletion gita/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ def _generate_dir_hash(repo_path: str, paths: List[str]) -> Tuple[
For example, if `repo_path` is /a/b/c/d/here, and one of `paths` is /a/b/
then return (b, c, d)
"""
print(paths, repo_path, '*'*5)
for p in paths:
rel = get_relative_path(repo_path, p)[:-1]
if rel is not None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup(
name='gita',
packages=['gita'],
version='0.15.6.4',
version='0.15.7',
license='MIT',
description='Manage multiple git repos with sanity',
long_description=long_description,
Expand Down

0 comments on commit dcb74c7

Please sign in to comment.