-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 git-init in case master
is not the default branch
#2835
Conversation
Hi @vinamra28. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This PR cannot be merged: expecting exactly one kind/ label Available
|
/ok-to-test |
@vdemeester could you please take a look at the PR 🙂 |
pkg/git/git.go
Outdated
@@ -65,7 +65,7 @@ func Fetch(logger *zap.SugaredLogger, spec FetchSpec) error { | |||
} | |||
|
|||
if spec.Revision == "" { | |||
spec.Revision = "master" | |||
spec.Revision = "HEAD" |
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 think we should run git symbolic-ref refs/remotes/origin/HEAD
only if spec.Revision
is empty and extract the default branch name from it. So something like :
remoteHead, err := run(logger, "", "symbolic-ref", "refs/remotes/origin/HEAD")
if err != nil {
return err
}
spec.Revision = strings.ReplaceAll(remoteHead, "refs/remotes/origin/", "") // this would display `master` or `main`, or …
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.
@vdemeester : I tried this out locally on my terminal and also as you suggested but this didn't worked out. On my terminal I got the following error:-
[vinjain@vinjain output]$ git remote show origin
* remote origin
Fetch URL: https://github.com/spring-projects/spring-petclinic.git
Push URL: https://github.com/spring-projects/spring-petclinic.git
HEAD branch: main
Remote branches:
gh-pages new (next fetch will store in remotes/origin)
main new (next fetch will store in remotes/origin)
wavefront new (next fetch will store in remotes/origin)
[vinjain@vinjain output]$ git symbolic-ref refs/remotes/origin/HEAD
fatal: ref refs/remotes/origin/HEAD is not a symbolic ref
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.
@vinamra28 you are right, it needs to happend after the fetch 🤔
fd38d0e
to
f5ec9c7
Compare
/retest |
f5ec9c7
to
12d3a8c
Compare
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 think we should have an e2e test that runs against sprint-petclinic
or a tektoncd/* controlled repository with a default branch with non master
to make sure it works fine 👼
12d3a8c
to
6eff8c4
Compare
@vdemeester added e2e tests as well for both |
The following is the coverage report on the affected files.
|
4cc2688
to
fde0cfb
Compare
The following is the coverage report on the affected files.
|
fde0cfb
to
12903d9
Compare
The following is the coverage report on the affected files.
|
12903d9
to
c0eb888
Compare
/test pull-tekton-pipeline-integration-tests |
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.
/lgtm
func getGitPipelineResourceSpringPetClinic(revision, refspec, sslverify, httpproxy, httpsproxy, noproxy string) *v1alpha1.PipelineResource { | ||
return tb.PipelineResource(gitSourceResourceName, tb.PipelineResourceSpec( | ||
v1alpha1.PipelineResourceTypeGit, | ||
tb.PipelineResourceSpecParam("Url", "https://github.com/spring-projects/spring-petclinic"), |
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 think, long term, we should use a project we control (just in case) 😝
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.
actually there was no repo in tektoncd/*
which does not have master
as the default branch. Earlier we had the v1beta1
branch in tektoncd/catalog
as the default branch but now it has been merged to master
. That's why I went to spring-petclinic
repo for testing 😅
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.
@vinamra28 yep, that's fine for now 😉
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.
Created #2854 to track.
I think there are two more things that need to be resolved and then this is ready to merge:
As an aside, we'll need to also update documentation for the |
Thank you @sbwsg. Will do this. Thanks for guidance 😄 |
This fix will patch the `git-init` such that if user doesn't provides revision then instead of taking `master` as the default branch we are doing the `symbolic-link` to the HEAD branch. Also added e2e tests for it. Signed-off-by: vinamra28 <[email protected]>
c0eb888
to
87c23e1
Compare
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg, vdemeester The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-tekton-pipeline-integration-tests |
Changes
This fix will patch the
git-init
such that if user doesn't provides revision then instead of takingmaster
as the default branch we are doing thesymbolic-link
to the HEAD branch. Instead of making the assumption that we should use master when the revision is empty, we are inspecting the remote.Fixes #2822
Signed-off-by: vinamra28 [email protected]
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes
/kind bug