Skip to content

clean up use get_source_tarball_from_git to use same checkout mechanism for creating tarball for Git repos with tags and commits#4797

Merged
boegel merged 4 commits intoeasybuilders:5.0.xfrom
lexming:fix-git-clone
Mar 7, 2025
Merged

clean up use get_source_tarball_from_git to use same checkout mechanism for creating tarball for Git repos with tags and commits#4797
boegel merged 4 commits intoeasybuilders:5.0.xfrom
lexming:fix-git-clone

Conversation

@lexming
Copy link
Copy Markdown
Contributor

@lexming lexming commented Mar 6, 2025

This PR is an extensive code cleanup of get_source_tarball_from_git (+25 -61). There are no changes in behaviour and one little bugfix.

Follow-up to the issues investigated in #4793

Motivation:

  • We got into a situation where the code checking out sources from git tags and commits is very different, but git tags and commits are the same thing. So there is no reason for such a difference, this PR unifies both checkouts to work in the same exact way. The unified procedure is the same currently used for commits:
    1. git clone --no-checkout {repo}
    2. git checkout {tag/commit}
    3. (if submodules) git submodules update --init ...
  • Sometimes git clone is shallow (with --depth 1), but in all such cases we end up unshallowing the repo. So there is no speed gain in any case. And this is expected, since we only checkout specific tags or commits (that's required), we cannot know how old those are, so we always have to fetch the full history of the repo. So this PR removes shallow clones in all cases.
  • There is a bunch of logic handling branches which is unnecessary. To checkout tags or commits, it doesn't matter how many branches has the repo, or which one is the active one. So this PR removes all logic related to branches.
  • The git_config option recurse-submodules is currently broken. The git option --recurse-submodules can only be used with a list of pathspecs in git clone, not in git submodule as it is currently done. The fix is rather simple, we can pass those pathspecs in the same way directly to git submodule without any --recurse-submodules

This PR adds several new tests to test_github_get_source_tarball_from_git to tests all these features with a test repo. Currently most of these features are not tested at all beyond checking the git command generated by get_source_tarball_from_git.

The new tests need a companion PR to https://github.com/easybuilders/testrepository

update: companion PR ready

@lexming lexming added this to the 5.0 milestone Mar 6, 2025
@boegel boegel changed the title use same checkout mechanism for git repos with tags and commits clean up use get_source_tarball_from_git` to use same checkout mechanism for creating tarball for Git repos with tags and commits Mar 7, 2025
Copy link
Copy Markdown
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@boegel boegel merged commit 1449822 into easybuilders:5.0.x Mar 7, 2025
@lexming lexming deleted the fix-git-clone branch March 7, 2025 10:22
@boegel boegel changed the title clean up use get_source_tarball_from_git` to use same checkout mechanism for creating tarball for Git repos with tags and commits clean up use get_source_tarball_from_git to use same checkout mechanism for creating tarball for Git repos with tags and commits Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants