-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: Enable --skip-clone-no-changes for fork PRs (#3891) #3900
base: main
Are you sure you want to change the base?
fix: Enable --skip-clone-no-changes for fork PRs (#3891) #3900
Conversation
did you ever tried this : https://www.runatlantis.io/docs/server-configuration.html#checkout-depth |
I did not, but I was able to confirm that hasRepoCfg is always false for fork PRs. Since that is the case a clone will always performed, which seems to contradict the docs for Can you elaborate on how |
I thought your concern was the size of the clone and not the amount of git clone invocations |
The size is not an issue if Without this change the call to Since deploying this branch yesterday, many forked PRs have skipped the cloning flow: Logs
|
Hi @jamengual, just bumping this thread in hopes this bug fix can get merged in! |
@Ulminator Can you resolve the file conflict and we'll get this in the next patch release. Thanks |
Head branch was pushed to by a user without write access
a0ca05d
to
5e40641
Compare
@GenPage just letting you know that I fixed the merge conflicts! |
5e40641
to
aa58a11
Compare
func (c *GiteaClient) GetFileContent(logger logging.SimpleLogging, pull models.PullRequest, fileName string) (bool, []byte, error) { | ||
logger.Debug("Getting file content for %s in Gitea pull request %d", fileName, pull.Num) | ||
|
||
content, resp, err := c.giteaClient.GetContents(pull.BaseRepo.Owner, pull.BaseRepo.Name, pull.HeadCommit, fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change removing the models.PullRequest
from the interface I opted to changing the head commit here to the branch name which seems to be supported by the docs.
https://pkg.go.dev/code.gitea.io/sdk/gitea#Client.GetContents
The name of the commit/branch/tag. Default the repository’s default branch (usually master)
@runatlantis/maintainers I know this has been stagnant for awhile, but I'd really like to get this merged. Since I originally wrote this PR the |
@@ -347,7 +347,17 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex | |||
|
|||
if p.SkipCloneNoChanges && p.VCSClient.SupportsSingleFileDownload(ctx.Pull.BaseRepo) { | |||
repoCfgFile := p.GlobalCfg.RepoConfigFile(ctx.Pull.BaseRepo.ID()) | |||
hasRepoCfg, repoCfgData, err := p.VCSClient.GetFileContent(ctx.Log, ctx.Pull, repoCfgFile) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for this new code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a test case, regenerated the mock_client.go file with pegomock, and fixed the issue w/ the DCO status check on my first commit.
The test also made it clear I could simplify some of the logic with just always passing the HeadRepo
to GetFileContent
. The prior issue being the repoCfgFile
never being found when attempting to get it from the HeadBranch
on the BaseRepo
, but that branch not existing as it is just on the HeadRepo
in the case of a forked PR.
Signed-off-by: Matt Ulmer <[email protected]>
Signed-off-by: Matt Ulmer <[email protected]>
4f2fa3d
to
d209151
Compare
Signed-off-by: Matt Ulmer <[email protected]>
what
This PR performs a check on whether the Atlantis PR is from a forked repo or not before making the call to
GetFileContent
to fetch the repo level atlantis.yaml file.why
While working in a monorepo that others would fork, the disk space on the VM that Atlantis runs on was quickly filled up as every PR made would be cloned. This should not happen when the
--skip-clone-no-changes
flag is used, but the logic for that currently ignores fork PRs.tests
I have deployed my branch and validated that PRs from forked repos are not cloned if the files changed in them are outside project directories.
make test
passed as well.Our workflow only uses the GitHub client so the implementation of the GitLab client has not been tested.
references