Skip to content

Commit

Permalink
Fixes #188 for check
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-edna committed Jul 16, 2021
1 parent 07c670c commit dd7bb22
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dfetch/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,26 @@ def create_menu(subparsers: "argparse._SubParsersAction") -> None:
action="store_true",
help="Don't recursively check for child manifests.",
)
parser.add_argument(
"projects",
metavar="<project>",
type=str,
nargs="*",
help="Specific project(s) to check",
)

def __call__(self, args: argparse.Namespace) -> None:
"""Perform the check."""
manifest, path = dfetch.manifest.manifest.get_manifest()

with in_directory(os.path.dirname(path)):
exceptions: List[str] = []
for project in manifest.projects:
projects = manifest.selected_projects(args.projects)
if not projects:
raise RuntimeError(
f"No (such) projects found! {', '.join(args.projects)}"
)
for project in projects:
with catch_runtime_exceptions(exceptions) as exceptions:
dfetch.project.make(project).check_for_update()

Expand Down
10 changes: 10 additions & 0 deletions dfetch/manifest/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ def projects(self) -> Sequence[ProjectEntry]:
"""Get a list of Projects from the manifest."""
return list(self._projects.values())

def selected_projects(self, names: Sequence[str]) -> Sequence[ProjectEntry]:
"""Get a list of Projects from the manifest with the given names."""
return (
list(
project for project in self._projects.values() if project.name in names
)
if names
else list(self._projects.values())
)

@property
def remotes(self) -> Sequence[Remote]:
"""Get a list of Remotes from the manifest."""
Expand Down
32 changes: 32 additions & 0 deletions features/check-specific-projects.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Feature: Checking specific projects

*DFetch* can check specific projects, this is usefull when you have a lot
of projects in your manifest.

Scenario: Single project is checked
Given the manifest 'dfetch.yaml'
"""
manifest:
version: '0.0'
remotes:
- name: github-com-dfetch-org
url-base: https://github.com/dfetch-org/test-repo
projects:
- name: ext/test-repo-rev-only
revision: e1fda19a57b873eb8e6ae37780594cbb77b70f1a
dst: ext/test-repo-rev-only
- name: ext/test-rev-and-branch
revision: 8df389d0524863b85f484f15a91c5f2c40aefda1
branch: main
dst: ext/test-rev-and-branch
"""
When I run "dfetch check ext/test-rev-and-branch"
Then the output shows
"""
Dfetch (0.2.0)
ext/test-rev-and-branch: wanted (main - 8df389d0524863b85f484f15a91c5f2c40aefda1), available (main - e1fda19a57b873eb8e6ae37780594cbb77b70f1a)
"""

0 comments on commit dd7bb22

Please sign in to comment.