summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-08-02 04:36:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-08-02 04:36:35 +0000
commit914dc999ae3c95404d65de193b8674a5e74075d9 (patch)
treec9ab69faedeed06244aff4d8d42c67b1723a2a22
parentReleasing debian version 0.15.1-1. (diff)
downloadgita-914dc999ae3c95404d65de193b8674a5e74075d9.tar.xz
gita-914dc999ae3c95404d65de193b8674a5e74075d9.zip
Merging upstream version 0.15.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--README.md12
-rw-r--r--gita/__main__.py17
-rw-r--r--setup.py2
-rw-r--r--tests/test_main.py15
4 files changed, 35 insertions, 11 deletions
diff --git a/README.md b/README.md
index 4b4c516..f18294e 100644
--- a/README.md
+++ b/README.md
@@ -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:
-- white: local has no remote
-- green: local is the same as remote
-- red: local has diverged from remote
-- purple: local is ahead of remote (good for push)
-- yellow: local is behind remote (good for merge)
+color | meaning
+---|---
+ white| local has no remote
+ green| local is the same as remote
+ 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
[blueshift](https://en.wikipedia.org/wiki/Blueshift) and [redshift](https://en.wikipedia.org/wiki/Redshift),
diff --git a/gita/__main__.py b/gita/__main__.py
index ee4e7e7..8678d36 100644
--- a/gita/__main__.py
+++ b/gita/__main__.py
@@ -178,8 +178,12 @@ def f_group(args: argparse.Namespace):
groups = utils.get_groups()
cmd = args.group_cmd or 'll'
if cmd == 'll':
- for group, repos in groups.items():
- print(f"{group}: {' '.join(repos)}")
+ if 'to_show' in args and args.to_show:
+ gname = args.to_show
+ print(' '.join(groups[gname]))
+ else:
+ for group, repos in groups.items():
+ print(f"{group}: {' '.join(repos)}")
elif cmd == 'ls':
print(' '.join(groups))
elif cmd == 'rename':
@@ -339,9 +343,10 @@ def f_shell(args):
chosen[r] = repos[r]
repos = chosen
cmds = ' '.join(args.man[i:]) # join the shell command into a single string
+ #cmds = args.man[i:]
for name, prop in repos.items():
# 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,
stderr=subprocess.STDOUT)
print(utils.format_output(got.stdout.decode(), name))
@@ -526,7 +531,11 @@ def main(argv=None):
p_group.set_defaults(func=f_group)
group_cmds = p_group.add_subparsers(dest='group_cmd',
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.')
pg_add = group_cmds.add_parser('add', description='Add repo(s) to a group.')
pg_add.add_argument('to_group',
diff --git a/setup.py b/setup.py
index 6fb92eb..bc82040 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('README.md', encoding='utf-8') as f:
setup(
name='gita',
packages=['gita'],
- version='0.15.1',
+ version='0.15.2',
license='MIT',
description='Manage multiple git repos with sanity',
long_description=long_description,
diff --git a/tests/test_main.py b/tests/test_main.py
index 490f5d2..d000e1a 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -287,7 +287,7 @@ def test_shell(mock_run, _, input):
args = ['shell', 'repo7', input]
__main__.main(args)
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:
@@ -348,6 +348,7 @@ class TestGroupCmd:
args = argparse.Namespace()
args.to_group = None
args.group_cmd = None
+ args.to_show = None
utils.get_groups.cache_clear()
__main__.f_group(args)
out, err = capfd.readouterr()
@@ -355,6 +356,18 @@ class TestGroupCmd:
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.utils.write_to_groups_file')
def test_rename(self, mock_write, _):
args = argparse.Namespace()