Skip to content

Commit

Permalink
fix rename repo issue: group file is not updated (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosarthur authored Jan 9, 2022
1 parent 5166e98 commit 2b15421
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 25 deletions.
2 changes: 0 additions & 2 deletions gita/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ def f_freeze(_):
seen = {''}
for name, prop in repos.items():
path = prop['path']
# TODO: What do we do with main repos? Maybe give an option to print
# their sub-repos too.
url = ''
# FIXME: capture_output is new in 3.7. Maybe drop support for 3.6
cp = subprocess.run(['git', 'remote', '-v'], cwd=path,
Expand Down
24 changes: 6 additions & 18 deletions gita/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_context() -> Union[Path, None]:


@lru_cache()
def get_groups() -> Dict[str, Dict]:
def get_groups() -> Dict[str, Dict[str, Union[str, List]]]:
"""
Return a `dict` of group name to group properties such as repo names and
group path.
Expand Down Expand Up @@ -211,27 +211,15 @@ def rename_repo(repos: Dict[str, Dict[str, str]], repo: str, new_name: str):
prop = repos[repo]
del repos[repo]
repos[new_name] = prop
# write to local config if inside a main path
main_paths = (prop['path'] for prop in repos.values() if prop['type'] == 'm')
cwd = os.getcwd()
is_local_config = True
# TODO: delete
for p in main_paths:
if get_relative_path(cwd, p) != MAX_INT:
write_to_repo_file(repos, 'w', p)
break
else: # global config
write_to_repo_file(repos, 'w')
is_local_config = False
# update groups only when outside any main repos
if is_local_config:
return
write_to_repo_file(repos, 'w')

groups = get_groups()
for g, members in groups.items():
for g, values in groups.items():
members = values['repos']
if repo in members:
members.remove(repo)
members.append(new_name)
groups[g] = sorted(members)
groups[g]['repos'] = sorted(members)
write_to_groups_file(groups, 'w')


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.16.0',
version='0.16.1',
license='MIT',
description='Manage multiple git repos with sanity',
long_description=long_description,
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def fullpath(fname: str):
PATH_FNAME = fullpath('mock_path_file')
PATH_FNAME_EMPTY = fullpath('empty_path_file')
PATH_FNAME_CLASH = fullpath('clash_path_file')
PATH_FNAME_MAIN = fullpath('main_path_file')
GROUP_FNAME = fullpath('mock_group_file')

def async_mock():
Expand Down
2 changes: 0 additions & 2 deletions tests/main_path_file

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from gita import __main__
from gita import utils, info, common
from conftest import (
PATH_FNAME, PATH_FNAME_EMPTY, PATH_FNAME_CLASH, GROUP_FNAME, PATH_FNAME_MAIN,
PATH_FNAME, PATH_FNAME_EMPTY, PATH_FNAME_CLASH, GROUP_FNAME,
async_mock, TEST_DIR,
)

Expand Down

0 comments on commit 2b15421

Please sign in to comment.