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

Cloning fails for repos using 'main' as the default branch name #286

Closed
marcomicera opened this issue Sep 23, 2020 · 5 comments
Closed

Cloning fails for repos using 'main' as the default branch name #286

marcomicera opened this issue Sep 23, 2020 · 5 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@marcomicera
Copy link
Contributor

Bug description

When omitting the branch name (GIT_SYNC_BRANCH/--branch), I would assume that the default branch would be synced.
The default branch name has been hardcoded as "master", but that's not always the case (junit uses "main", for instance).

MWE

Just cloning a repo and listing its content.

apiVersion: batch/v1
kind: Job
metadata:
  name: clone-main-branch
spec:
  backoffLimit: 1
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: lister
        image: alpine
        command: [ "sh", "-c", "ls /home/project" ]
        volumeMounts:
        - name: repo-volume
          mountPath: /home
      initContainers:
      - name: cloner
        image: k8s.gcr.io/git-sync/git-sync:v3.1.7
        env:
#          - name: GIT_SYNC_REPO
#            value: https://github.com/google/guava # Works. Default branch name: master.
          - name: GIT_SYNC_REPO
            value: http://github.com/junit-team/junit # Doesn't work. Default branch name: main.
          - name: GIT_SYNC_ROOT
            value: /home
          - name: GIT_SYNC_DEST
            value: project
          - name: GIT_SYNC_ONE_TIME
            value: "1"
          - name: GIT_SYNC_DEPTH
            value: "1"
          - name: GIT_SYNC_SUBMODULES
            value: "shallow"
        volumeMounts:
          - name: repo-volume
            mountPath: /home
      volumes:
      - name: repo-volume
        emptyDir: {}

Proposed solution

  1. Set the default branch name to an empty string or nil.
  2. Avoid using git's -b flag when the previous variable is empty/nil.
@thockin
Copy link
Member

thockin commented Sep 25, 2020

This is a reasonable change but could be breaking. If we're going to do this, let's do it in context of a v4 branch.

@stp-ip
Copy link
Member

stp-ip commented Sep 25, 2020

I agree that this is a breaking change and a bad one in terms of user impact. So v4 is needed I agree.

For context. Git itself (https://lore.kernel.org/git/xmqq4kp8903z.fsf@gitster.c.googlers.com/T/#t) hasn't finished their migration so there is still time until this will be breaking more users in both directions. So far one can set a branch and it works, so users with "main" as default branch already know how to circumvent the breaking.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 24, 2020
@thockin
Copy link
Member

thockin commented Dec 24, 2020

/lifecycle frozen
/remove-lifecycle stale
/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 24, 2020
totycro added a commit to eurodatacube/pygeoapi-kubernetes-papermill that referenced this issue Sep 21, 2021
It allows checking out repos where the default branch name isn't master

kubernetes/git-sync#286
@thockin
Copy link
Member

thockin commented Aug 20, 2022

Fixed in v4 branch

@thockin thockin closed this as completed Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

5 participants