Closed
Description
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
- Set the default branch name to an empty string or
nil
. - Avoid using
git
's-b
flag when the previous variable is empty/nil
.