Skip to content

Commit

Permalink
Use at least --shallow-since when git_shallow_fetch is enabled
Browse files Browse the repository at this point in the history
When git_shallow_fetch feature is requested, even when we need to
compute a changelog, we should not fetch the full depth of the
repository. Just fetch at the required depth instead.
  • Loading branch information
pierretr committed Jun 28, 2024
1 parent 8cec457 commit 2b60353
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/e3/anod/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,21 @@ def update_git(

try:
old_commit = g.rev_parse()

shallow_cmd: str | None = None
# Using fetch + checkout ensure caching is effective
shallow = "git_shallow_fetch" in os.environ.get(
"E3_ENABLE_FEATURE", ""
).split(",") and (not self.compute_changelog or not old_commit)
).split(",")
if shallow and (not self.compute_changelog or not old_commit):
shallow_cmd = "--depth=1"
else:
shallow_cmd = f"--shallow-since={old_commit}"

g.git_cmd(
[
"fetch",
"-f",
"--depth=1" if shallow else None,
shallow_cmd,
remote_name,
f"{revision}:refs/e3-checkout",
]
Expand Down

0 comments on commit 2b60353

Please sign in to comment.