Skip to content

Commit

Permalink
Adding more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
IanWoodard committed Jan 16, 2025
1 parent 933a340 commit 87fde96
Show file tree
Hide file tree
Showing 2 changed files with 380 additions and 10 deletions.
22 changes: 12 additions & 10 deletions devservices/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,7 @@ def _update_dependency(

# Check if the local repo is up-to-date
try:
local_commit = subprocess.check_output(
["git", "rev-parse", "HEAD"],
cwd=dependency_repo_dir,
stderr=subprocess.PIPE,
).strip()
local_commit = _rev_parse(dependency_repo_dir, "HEAD")
except subprocess.CalledProcessError as e:
raise DependencyError(

Check warning on line 491 in devservices/utils/dependencies.py

View check run for this annotation

Codecov / codecov/patch

devservices/utils/dependencies.py#L490-L491

Added lines #L490 - L491 were not covered by tests
repo_name=dependency.repo_name,
Expand All @@ -499,11 +495,7 @@ def _update_dependency(
) from e

try:
remote_commit = subprocess.check_output(
["git", "rev-parse", "FETCH_HEAD"],
cwd=dependency_repo_dir,
stderr=subprocess.PIPE,
).strip()
remote_commit = _rev_parse(dependency_repo_dir, "FETCH_HEAD")
except subprocess.CalledProcessError as e:
raise DependencyError(

Check warning on line 500 in devservices/utils/dependencies.py

View check run for this annotation

Codecov / codecov/patch

devservices/utils/dependencies.py#L499-L500

Added lines #L499 - L500 were not covered by tests
repo_name=dependency.repo_name,
Expand Down Expand Up @@ -622,6 +614,16 @@ def _has_remote_config(remote_config: RemoteConfig | None) -> TypeGuard[RemoteCo
return remote_config is not None


def _rev_parse(repo_dir: str, ref: str) -> str:
return (
subprocess.check_output(
["git", "rev-parse", ref], cwd=repo_dir, stderr=subprocess.PIPE
)
.strip()
.decode()
)


def _run_command(
cmd: list[str], cwd: str, stdout: int | TextIO | None = subprocess.DEVNULL
) -> None:
Expand Down
Loading

0 comments on commit 87fde96

Please sign in to comment.