-
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?
Changes from all commits
cc5e77c
1fb9cd5
d209151
d61c9b7
b01c67b
56c3327
b0def7d
711f614
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -421,13 +421,11 @@ func (c *GiteaClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([ | |
// GetFileContent a repository file content from VCS (which support fetch a single file from repository) | ||
// The first return value indicates whether the repo contains a file or not | ||
// if BaseRepo had a file, its content will placed on the second return value | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. With this change removing the 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) |
||
func (c *GiteaClient) GetFileContent(logger logging.SimpleLogging, repo models.Repo, branch string, fileName string) (bool, []byte, error) { | ||
content, resp, err := c.giteaClient.GetContents(repo.Owner, repo.Name, branch, fileName) | ||
|
||
if err != nil { | ||
logger.Debug("GET /repos/%v/%v/contents/%s?ref=%v returned: %v", pull.BaseRepo.Owner, pull.BaseRepo.Name, fileName, pull.HeadCommit, resp.StatusCode) | ||
logger.Debug("GET /repos/%v/%v/contents/%s?ref=%v returned: %v", repo.Owner, repo.Name, fileName, branch, resp.StatusCode) | ||
return false, nil, err | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
toGetFileContent
. The prior issue being therepoCfgFile
never being found when attempting to get it from theHeadBranch
on theBaseRepo
, but that branch not existing as it is just on theHeadRepo
in the case of a forked PR.