1
0
Fork 0

Adding upstream version 0.15.8.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-11 18:45:00 +01:00
parent 6204f01115
commit 495df48c0a
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
6 changed files with 91 additions and 72 deletions

View file

@ -256,6 +256,10 @@ def write_to_groups_file(groups: Dict[str, Dict], mode: str):
if not groups: # all groups are deleted
open(fname, 'w').close()
else:
# delete the group if there are no repos
for name in list(groups):
if not groups[name]['repos']:
del groups[name]
with open(fname, mode, newline='') as f:
data = [
(group, ' '.join(prop['repos']), prop['path'])
@ -475,3 +479,38 @@ def get_cmds_from_files() -> Dict[str, Dict[str, str]]:
# custom commands shadow default ones
cmds.update(custom_cmds)
return cmds
def parse_repos_and_rest(input: List[str]
) -> Tuple[Dict[str, Dict[str, str]], List[str]]:
"""
Parse gita input arguments
@return: repos and the rest (e.g., gita shell and super commands)
"""
i = None
names = []
repos = get_repos()
groups = get_groups()
ctx = get_context()
for i, word in enumerate(input):
if word in repos or word in groups:
names.append(word)
else:
break
else: # all input is repos and groups, shift the index once more
if i is not None:
i += 1
if not names and ctx:
names = [ctx.stem]
if names:
chosen = {}
for k in names:
if k in repos:
chosen[k] = repos[k]
if k in groups:
for r in groups[k]['repos']:
chosen[r] = repos[r]
# if not set here, all repos are chosen
repos = chosen
return repos, input[i:]