-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add groups in gita freeze output (#272)
* enhance freeze and clone for groups * update github actions * fix unit tests
- Loading branch information
Showing
6 changed files
with
79 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import csv | ||
from typing import Tuple | ||
|
||
|
||
def parse_clone_config(fname: str) -> Tuple: | ||
""" | ||
Return the repo information (url, name, path, type) and group information | ||
(, name, path, repos) saved in `fname`. | ||
""" | ||
repos = {} | ||
groups = {} | ||
if os.path.isfile(fname) and os.stat(fname).st_size > 0: | ||
with open(fname) as f: | ||
rows = csv.DictReader( | ||
f, ["url", "name", "path", "type", "flags"], restval="" | ||
) # it's actually a reader | ||
for r in rows: | ||
if r["url"]: | ||
repos[r["name"]] = { | ||
"path": r["path"], | ||
"type": r["type"], | ||
"flags": r["flags"].split(), | ||
"url": r["url"], | ||
} | ||
else: | ||
groups[r["name"]] = { | ||
"path": r["path"], | ||
"repos": [ | ||
repo for repo in r["type"].split("|") if repo in repos | ||
], | ||
} | ||
return repos, groups |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,8 +196,11 @@ def test_clone_with_url(mock_run): | |
|
||
|
||
@patch( | ||
"gita.utils.parse_clone_config", | ||
return_value=[["[email protected]:user/repo.git", "repo", "/a/repo"]], | ||
"gita.io.parse_clone_config", | ||
return_value=( | ||
{"repo": {"url": "[email protected]:user/repo.git", "path": "/a/repo"}}, | ||
{}, | ||
), | ||
) | ||
@patch("gita.utils.run_async", new=async_mock()) | ||
@patch("subprocess.run") | ||
|
@@ -217,8 +220,11 @@ def test_clone_with_config_file(*_): | |
|
||
|
||
@patch( | ||
"gita.utils.parse_clone_config", | ||
return_value=[["[email protected]:user/repo.git", "repo", "/a/repo"]], | ||
"gita.io.parse_clone_config", | ||
return_value=( | ||
{"repo": {"url": "[email protected]:user/repo.git", "path": "/a/repo"}}, | ||
{}, | ||
), | ||
) | ||
@patch("gita.utils.run_async", new=async_mock()) | ||
@patch("subprocess.run") | ||
|