Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: shallow repo clone in merge checkout strategy #2758

Merged
merged 36 commits into from
Feb 22, 2023

Conversation

nitrocode
Copy link
Member

@nitrocode nitrocode commented Dec 7, 2022

what

  • Allow shallow cloning for merge checkout strategy
  • The default check out is set to 0

why

  • Faster clones for repos with a long history using the merge strategy. If the checkout cannot do the merge with a shallow clone then the full clone is checked out.
  • The new flag to set the --checkout-depth for the merge check out strategy continues to default to 0 to avoid breaking any existing users
  • The branch strategy already uses shallow cloning by cloning with a depth of 1 (unchanged)
  • This new PR was opened in order to resolve conflicts. The old PR did not allow maintainer updates.

"git", "clone", "--branch", p.HeadBranch, "--depth=1", "--single-branch", headCloneURL, cloneDir,

references

When the repository is quite large clones are becoming slower. Previously Atlantis fetched full repository in --checkout-strategy=merge mode.
However, that's not required, we only should have enough commits in our clone to perform a merge between base and feature branches, not full history.
This implements rough guessing: fetch 50 (user-configurable) commits from each of base and feature branches, and if their merge base is not in these commits, fetch full repo history. This is not ideal solution and could be improved (e.g. increase the number of fetched commits in several attempts before full fetch), but I think it should be good enough in most cases.
@nitrocode nitrocode requested a review from a team as a code owner December 7, 2022 01:58
@nitrocode
Copy link
Member Author

nitrocode commented Dec 7, 2022

@rationalex @ibonder @Radcriminal @nikolaik @jilyaluk

You folks all upvoted the previous PR. I tried my best to bring this back to life but I'm not completely sure why the original change by @jilyaluk was only for the non-default checkout strategy of merge instead of branch or instead of both. If you folks can explain that, it would help because this change does modify a lot of how atlantis clones repos.

A review would also be helpful by maintainers and anyone else willing to look this over. I'm not so savvy and don't have a huge vested interest in this so I do not plan to make additional changes as I do not use the merge checkout strategy.

Edit: it's already enabled for branch strategy

"git", "clone", "--branch", p.HeadBranch, "--depth=1", "--single-branch", headCloneURL, cloneDir,

nitrocode and others added 2 commits December 7, 2022 10:05
@nitrocode nitrocode changed the title Implement shallow repo clone in merge checkout strategy feat: Implement shallow repo clone in merge checkout strategy Dec 9, 2022
@nitrocode nitrocode changed the title feat: Implement shallow repo clone in merge checkout strategy feat: shallow repo clone in merge checkout strategy Dec 9, 2022
@nitrocode nitrocode added Stale unmaintained Looking for community to build upon help wanted Good feature for contributors labels Dec 17, 2022
@nitrocode nitrocode removed help wanted Good feature for contributors unmaintained Looking for community to build upon Stale labels Dec 22, 2022
@nitrocode nitrocode requested review from nikolaik and removed request for nikolaik December 22, 2022 22:36
@nitrocode nitrocode requested review from nikolaik and krrrr38 and removed request for nikolaik February 19, 2023 14:34
Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
@nitrocode nitrocode requested a review from chenrui333 February 22, 2023 05:50
@nitrocode nitrocode enabled auto-merge (squash) February 22, 2023 05:51
@nitrocode nitrocode merged commit ad2274f into main Feb 22, 2023
@nitrocode nitrocode deleted the feature/shallow-clone branch February 22, 2023 21:29
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Implement shallow repo clone in merge checkout strategy

---------

Co-authored-by: Ilya Lukyanov <il@joom.com>
Co-authored-by: Nikolai Røed Kristiansen <nikolaik@gmail.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Implement shallow repo clone in merge checkout strategy

---------

Co-authored-by: Ilya Lukyanov <il@joom.com>
Co-authored-by: Nikolai Røed Kristiansen <nikolaik@gmail.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation feature New functionality/enhancement go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants