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

git-init: do not assume master as default branch #2822

Closed
vdemeester opened this issue Jun 16, 2020 · 1 comment · Fixed by #2835
Closed

git-init: do not assume master as default branch #2822

vdemeester opened this issue Jun 16, 2020 · 1 comment · Fixed by #2835
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@vdemeester
Copy link
Member

vdemeester commented Jun 16, 2020

As of today, when the user doesn't specific a revision (branch, commit, …), we are defaulting to master. There is some problems with that: master might not be present on the remote. The recent wave of change of default branches on several project, including https:/spring-projects/spring-petclinic are putting this problem into light : see tektoncd/catalog#365.

Instead of making the assumption that we should use master when the revision is empty, we should inspect the remote. git can give us this information.

$ git remote show origin
* remote origin
  Fetch URL: https:/spring-projects/spring-petclinic
  Push  URL: https:/spring-projects/spring-petclinic
  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)

After doing the git init and adding the remote git remote add origin …, we should get the default branch (remote HEAD) if the revision isn't specified. The way to do it should be as simple as git symbolic-ref refs/remotes/origin/HEAD 👼

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 16, 2020
@vdemeester vdemeester added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jun 16, 2020
@vinamra28
Copy link
Member

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants