Skip to content

Commit

Permalink
git: implement unshallow
Browse files Browse the repository at this point in the history
If the repository was initially cloned shallow, the next 'git fetch'
will not undo that. Consequently, the user may be left wondering why the
commit is not fetched even though the shallow property was removed. To
fix that, Bob must pass the --unshallow option in this case.

Unfortunately it is not allowed by git to specify --unshallow
unconditionally. So always check if the repository is shallow and only
add --unshallow in this case.
  • Loading branch information
jkloetzke committed Nov 18, 2024
1 parent 7b44357 commit ee29e75
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pym/bob/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ async def invoke(self, invoker, switch=False):
fetchCmd.append("--depth={}".format(self.__shallow))
elif isinstance(self.__shallow, str):
fetchCmd.append("--shallow-since={}".format(self.__shallow))
elif await invoker.checkOutputCommand(["git", "rev-parse", "--is-shallow-repository"],
cwd=self.__dir) == "true":
fetchCmd.append("--unshallow")
fetchCmd.append("origin")

# Calculate appropriate refspec (all/singleBranch/tag)
Expand Down

0 comments on commit ee29e75

Please sign in to comment.