Adding upstream version 0.16.5.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
6e615d8555
commit
5416a64f41
6 changed files with 43 additions and 11 deletions
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
||||||
install:
|
install:
|
||||||
pip3 install -e .
|
pip3 install -e .
|
||||||
test:
|
test:
|
||||||
pytest tests --cov=./gita $(TEST_ARGS) -n=auto
|
pytest tests --cov=./gita $(TEST_ARGS) -n=auto -vv
|
||||||
dist:
|
dist:
|
||||||
python3 setup.py sdist
|
python3 setup.py sdist
|
||||||
twine:
|
twine:
|
||||||
|
|
|
@ -149,10 +149,20 @@ def f_info(args: argparse.Namespace):
|
||||||
|
|
||||||
|
|
||||||
def f_clone(args: argparse.Namespace):
|
def f_clone(args: argparse.Namespace):
|
||||||
|
|
||||||
|
if args.dry_run:
|
||||||
|
if args.from_file:
|
||||||
|
for url, repo_name, abs_path in utils.parse_clone_config(args.clonee):
|
||||||
|
print(f"git clone {url} {abs_path}")
|
||||||
|
else:
|
||||||
|
print(f"git clone {args.clonee}")
|
||||||
|
return
|
||||||
|
|
||||||
if args.directory:
|
if args.directory:
|
||||||
path = args.directory
|
path = args.directory
|
||||||
else:
|
else:
|
||||||
path = Path.cwd()
|
path = Path.cwd()
|
||||||
|
|
||||||
if not args.from_file:
|
if not args.from_file:
|
||||||
subprocess.run(["git", "clone", args.clonee], cwd=path)
|
subprocess.run(["git", "clone", args.clonee], cwd=path)
|
||||||
return
|
return
|
||||||
|
@ -169,9 +179,15 @@ def f_clone(args: argparse.Namespace):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def f_freeze(_):
|
def f_freeze(args):
|
||||||
# TODO: filter context
|
|
||||||
repos = utils.get_repos()
|
repos = utils.get_repos()
|
||||||
|
ctx = utils.get_context()
|
||||||
|
if args.group is None and ctx:
|
||||||
|
args.group = ctx.stem
|
||||||
|
group_repos = None
|
||||||
|
if args.group: # only display repos in this group
|
||||||
|
group_repos = utils.get_groups()[args.group]["repos"]
|
||||||
|
repos = {k: repos[k] for k in group_repos if k in repos}
|
||||||
seen = {""}
|
seen = {""}
|
||||||
for name, prop in repos.items():
|
for name, prop in repos.items():
|
||||||
path = prop["path"]
|
path = prop["path"]
|
||||||
|
@ -460,6 +476,12 @@ def main(argv=None):
|
||||||
description="print all repo information",
|
description="print all repo information",
|
||||||
help="print all repo information",
|
help="print all repo information",
|
||||||
)
|
)
|
||||||
|
p_freeze.add_argument(
|
||||||
|
"-g",
|
||||||
|
"--group",
|
||||||
|
choices=utils.get_groups(),
|
||||||
|
help="freeze repos in the specified group",
|
||||||
|
)
|
||||||
p_freeze.set_defaults(func=f_freeze)
|
p_freeze.set_defaults(func=f_freeze)
|
||||||
|
|
||||||
p_clone = subparsers.add_parser(
|
p_clone = subparsers.add_parser(
|
||||||
|
@ -487,6 +509,12 @@ def main(argv=None):
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="clone repo(s) in their original paths",
|
help="clone repo(s) in their original paths",
|
||||||
)
|
)
|
||||||
|
p_clone.add_argument(
|
||||||
|
"-n",
|
||||||
|
"--dry-run",
|
||||||
|
action="store_true",
|
||||||
|
help="If set, show command without execution",
|
||||||
|
)
|
||||||
p_clone.set_defaults(func=f_clone)
|
p_clone.set_defaults(func=f_clone)
|
||||||
|
|
||||||
p_rename = subparsers.add_parser(
|
p_rename = subparsers.add_parser(
|
||||||
|
|
|
@ -198,9 +198,10 @@ def get_commit_time(prop: Dict[str, str]) -> str:
|
||||||
def get_repo_status(prop: Dict[str, str], no_colors=False) -> str:
|
def get_repo_status(prop: Dict[str, str], no_colors=False) -> str:
|
||||||
head = get_head(prop["path"])
|
head = get_head(prop["path"])
|
||||||
dirty, staged, untracked, color = _get_repo_status(prop, no_colors)
|
dirty, staged, untracked, color = _get_repo_status(prop, no_colors)
|
||||||
|
info = f"{head:<10} [{dirty+staged+untracked}]"
|
||||||
if color:
|
if color:
|
||||||
return f"{color}{head+' ['+dirty+staged+untracked+']':<13}{Color.end}"
|
return f"{color}{info:<17}{Color.end}"
|
||||||
return f"{head+' ['+dirty+staged+untracked+']':<13}"
|
return f"{info:<17}"
|
||||||
|
|
||||||
|
|
||||||
def get_repo_branch(prop: Dict[str, str]) -> str:
|
def get_repo_branch(prop: Dict[str, str]) -> str:
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -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.16.4",
|
version="0.16.5",
|
||||||
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,
|
||||||
|
|
|
@ -130,12 +130,12 @@ class TestLsLl:
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
PATH_FNAME,
|
PATH_FNAME,
|
||||||
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \nxxx cmaster [dsu] \x1b[0m msg \n",
|
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \nxxx cmaster [dsu] \x1b[0m msg \n",
|
||||||
),
|
),
|
||||||
(PATH_FNAME_EMPTY, ""),
|
(PATH_FNAME_EMPTY, ""),
|
||||||
(
|
(
|
||||||
PATH_FNAME_CLASH,
|
PATH_FNAME_CLASH,
|
||||||
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \n",
|
"repo1 cmaster [dsu] \x1b[0m msg \nrepo2 cmaster [dsu] \x1b[0m msg \n",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -186,6 +186,7 @@ def test_clone_with_url(mock_run):
|
||||||
args.preserve_path = None
|
args.preserve_path = None
|
||||||
args.directory = "/home/xxx"
|
args.directory = "/home/xxx"
|
||||||
args.from_file = False
|
args.from_file = False
|
||||||
|
args.dry_run = False
|
||||||
__main__.f_clone(args)
|
__main__.f_clone(args)
|
||||||
cmds = ["git", "clone", args.clonee]
|
cmds = ["git", "clone", args.clonee]
|
||||||
mock_run.assert_called_once_with(cmds, cwd=args.directory)
|
mock_run.assert_called_once_with(cmds, cwd=args.directory)
|
||||||
|
@ -204,6 +205,7 @@ def test_clone_with_config_file(*_):
|
||||||
args.preserve_path = False
|
args.preserve_path = False
|
||||||
args.directory = None
|
args.directory = None
|
||||||
args.from_file = True
|
args.from_file = True
|
||||||
|
args.dry_run = False
|
||||||
__main__.f_clone(args)
|
__main__.f_clone(args)
|
||||||
mock_run = utils.run_async.mock
|
mock_run = utils.run_async.mock
|
||||||
assert mock_run.call_count == 1
|
assert mock_run.call_count == 1
|
||||||
|
@ -224,6 +226,7 @@ def test_clone_with_preserve_path(*_):
|
||||||
args.directory = None
|
args.directory = None
|
||||||
args.from_file = True
|
args.from_file = True
|
||||||
args.preserve_path = True
|
args.preserve_path = True
|
||||||
|
args.dry_run = False
|
||||||
__main__.f_clone(args)
|
__main__.f_clone(args)
|
||||||
mock_run = utils.run_async.mock
|
mock_run = utils.run_async.mock
|
||||||
assert mock_run.call_count == 1
|
assert mock_run.call_count == 1
|
||||||
|
|
|
@ -115,17 +115,17 @@ def test_auto_group(repos, paths, expected):
|
||||||
(
|
(
|
||||||
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, False],
|
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, False],
|
||||||
True,
|
True,
|
||||||
"abc \x1b[31mrepo [*+?] \x1b[0m msg xx",
|
"abc \x1b[31mrepo [*+?] \x1b[0m msg xx",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, True],
|
[{"abc": {"path": "/root/repo/", "type": "", "flags": []}}, True],
|
||||||
True,
|
True,
|
||||||
"abc repo [*+?] msg xx",
|
"abc repo [*+?] msg xx",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[{"repo": {"path": "/root/repo2/", "type": "", "flags": []}}, False],
|
[{"repo": {"path": "/root/repo2/", "type": "", "flags": []}}, False],
|
||||||
False,
|
False,
|
||||||
"repo \x1b[32mrepo [?] \x1b[0m msg xx",
|
"repo \x1b[32mrepo [?] \x1b[0m msg xx",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue