1
0
Fork 0

Adding upstream version 0.15.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-11 18:42:47 +01:00
parent f2586667ea
commit d8a18b006a
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4 changed files with 35 additions and 11 deletions

View file

@ -41,11 +41,13 @@ To run arbitrary shell command, see the [shell mode section](#shell).
The branch color distinguishes 5 situations between local and remote branches: The branch color distinguishes 5 situations between local and remote branches:
- white: local has no remote color | meaning
- green: local is the same as remote ---|---
- red: local has diverged from remote white| local has no remote
- purple: local is ahead of remote (good for push) green| local is the same as remote
- yellow: local is behind remote (good for merge) red| local has diverged from remote
purple| local is ahead of remote (good for push)
yellow| local is behind remote (good for merge)
The choice of purple for ahead and yellow for behind is motivated by The choice of purple for ahead and yellow for behind is motivated by
[blueshift](https://en.wikipedia.org/wiki/Blueshift) and [redshift](https://en.wikipedia.org/wiki/Redshift), [blueshift](https://en.wikipedia.org/wiki/Blueshift) and [redshift](https://en.wikipedia.org/wiki/Redshift),

View file

@ -178,8 +178,12 @@ def f_group(args: argparse.Namespace):
groups = utils.get_groups() groups = utils.get_groups()
cmd = args.group_cmd or 'll' cmd = args.group_cmd or 'll'
if cmd == 'll': if cmd == 'll':
for group, repos in groups.items(): if 'to_show' in args and args.to_show:
print(f"{group}: {' '.join(repos)}") gname = args.to_show
print(' '.join(groups[gname]))
else:
for group, repos in groups.items():
print(f"{group}: {' '.join(repos)}")
elif cmd == 'ls': elif cmd == 'ls':
print(' '.join(groups)) print(' '.join(groups))
elif cmd == 'rename': elif cmd == 'rename':
@ -339,9 +343,10 @@ def f_shell(args):
chosen[r] = repos[r] chosen[r] = repos[r]
repos = chosen repos = chosen
cmds = ' '.join(args.man[i:]) # join the shell command into a single string cmds = ' '.join(args.man[i:]) # join the shell command into a single string
#cmds = args.man[i:]
for name, prop in repos.items(): for name, prop in repos.items():
# TODO: pull this out as a function # TODO: pull this out as a function
got = subprocess.run(cmds, cwd=prop['path'], check=True, shell=True, got = subprocess.run(cmds, cwd=prop['path'], shell=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
print(utils.format_output(got.stdout.decode(), name)) print(utils.format_output(got.stdout.decode(), name))
@ -526,7 +531,11 @@ def main(argv=None):
p_group.set_defaults(func=f_group) p_group.set_defaults(func=f_group)
group_cmds = p_group.add_subparsers(dest='group_cmd', group_cmds = p_group.add_subparsers(dest='group_cmd',
help='additional help with sub-command -h') help='additional help with sub-command -h')
group_cmds.add_parser('ll', description='List all groups with repos.') pg_ll = group_cmds.add_parser('ll', description='List all groups with repos.')
pg_ll.add_argument('to_show',
nargs='?',
choices=utils.get_groups(),
help="group to show")
group_cmds.add_parser('ls', description='List all group names.') group_cmds.add_parser('ls', description='List all group names.')
pg_add = group_cmds.add_parser('add', description='Add repo(s) to a group.') pg_add = group_cmds.add_parser('add', description='Add repo(s) to a group.')
pg_add.add_argument('to_group', pg_add.add_argument('to_group',

View file

@ -7,7 +7,7 @@ with open('README.md', encoding='utf-8') as f:
setup( setup(
name='gita', name='gita',
packages=['gita'], packages=['gita'],
version='0.15.1', version='0.15.2',
license='MIT', license='MIT',
description='Manage multiple git repos with sanity', description='Manage multiple git repos with sanity',
long_description=long_description, long_description=long_description,

View file

@ -287,7 +287,7 @@ def test_shell(mock_run, _, input):
args = ['shell', 'repo7', input] args = ['shell', 'repo7', input]
__main__.main(args) __main__.main(args)
expected_cmds = input expected_cmds = input
mock_run.assert_called_once_with(expected_cmds, cwd='path7', check=True, shell=True, stderr=-2, stdout=-1) mock_run.assert_called_once_with(expected_cmds, cwd='path7', shell=True, stderr=-2, stdout=-1)
class TestContext: class TestContext:
@ -348,12 +348,25 @@ class TestGroupCmd:
args = argparse.Namespace() args = argparse.Namespace()
args.to_group = None args.to_group = None
args.group_cmd = None args.group_cmd = None
args.to_show = None
utils.get_groups.cache_clear() utils.get_groups.cache_clear()
__main__.f_group(args) __main__.f_group(args)
out, err = capfd.readouterr() out, err = capfd.readouterr()
assert err == '' assert err == ''
assert 'xx: a b\nyy: a c d\n' == out assert 'xx: a b\nyy: a c d\n' == out
@patch('gita.common.get_config_fname', return_value=GROUP_FNAME)
def test_ll_with_group(self, _, capfd):
args = argparse.Namespace()
args.to_group = None
args.group_cmd = None
args.to_show = 'yy'
utils.get_groups.cache_clear()
__main__.f_group(args)
out, err = capfd.readouterr()
assert err == ''
assert 'a c d\n' == out
@patch('gita.common.get_config_fname', return_value=GROUP_FNAME) @patch('gita.common.get_config_fname', return_value=GROUP_FNAME)
@patch('gita.utils.write_to_groups_file') @patch('gita.utils.write_to_groups_file')
def test_rename(self, mock_write, _): def test_rename(self, mock_write, _):