Skip to contentSkip to conversation

gitlab-ci: Be ready for new default 'main' branch name

PATCH In review Philippe Mathieu-Daudé 3 participants 4 messages May 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitlab-ci: Be ready for new default 'main' branch name

In order to be ready for the GitLab changes in using inclusive terminology (replacing the 'master' branch name by the 'main' branch name), rename our use of 'master' by the $CI_DEFAULT_BRANCH environment variable, so new forks won't be facing any issue.

References:

- https://sfconservancy.org/news/2020/jun/23/gitbranchname/
- https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

---
 .gitlab-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
.gitlab-ci.yml +2 -2
index f718b61fa78..db4e8490483 100644
@@ -784,7 +784,7 @@ check-patch:
   script: .gitlab-ci.d/check-patch.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000
   allow_failure: true
@@ -797,7 +797,7 @@ check-dco:
   script: .gitlab-ci.d/check-dco.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000
 
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé

In order to be ready for the GitLab changes in using inclusive terminology (replacing the 'master' branch name by the 'main' branch name), rename our use of 'master' by the $CI_DEFAULT_BRANCH environment variable, so new forks won't be facing any issue.

References:

Quoted 9 lines

- https://sfconservancy.org/news/2020/jun/23/gitbranchname/
- https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

---
 .gitlab-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

With changes to the description proposed by Daniel:

Quoted 25 lines
.gitlab-ci.yml +2 -3
index f718b61fa78..db4e8490483 100644
@@ -784,7 +784,7 @@ check-patch:
   script: .gitlab-ci.d/check-patch.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000
   allow_failure: true
@@ -797,7 +797,7 @@ check-dco:
   script: .gitlab-ci.d/check-dco.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000
 
--

2.26.3

Reviewed-by on v1 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

In order to be ready for the GitLab changes in using inclusive terminology (replacing the 'master' branch name by the 'main' branch name), rename our use of 'master' by the $CI_DEFAULT_BRANCH environment variable, so new forks won't be facing any issue.

I've no objection to the actual config change, but the description is little inaccurate IMHO. GitLab is not forcing a branch name change into any existing repositories. It is entirely upto QEMU to decide when to change our branch names. Forks of QEMU also won't get a new branch name, because any branches in forks are inherited from what exists in repository being forked and not arbitrarily renamed.

So, AFAICT, only brand new (ie empty) repositories will get 'main' as the new default branch name.

IOW, I'd describe this as

"We want to skip the checkpatch and DCO signoff jobs when
pushing to the default branch. Currently this branch is called 'master', but we don't need to hardcode this in the CI configuration, because the $CI_DEFAULT_BRANCH env variable exposes it."

Quoted 14 lines
.gitlab-ci.yml +1 -1
index f718b61fa78..db4e8490483 100644
@@ -784,7 +784,7 @@ check-patch:
   script: .gitlab-ci.d/check-patch.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000
   allow_failure: true

.gitlab-ci.yml check-dco: · line 802

Quoted 7 lines
.gitlab-ci.yml +1 -1
@@ -797,7 +797,7 @@ check-dco:
   script: .gitlab-ci.d/check-dco.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw
Quoted 6 lines · Daniel P. Berrangé
Quoted 4 lines · Philippe Mathieu-Daudé

In order to be ready for the GitLab changes in using inclusive terminology (replacing the 'master' branch name by the 'main' branch name), rename our use of 'master' by the $CI_DEFAULT_BRANCH environment variable, so new forks won't be facing any issue.

Quoted 6 lines

I've no objection to the actual config change, but the description is little inaccurate IMHO. GitLab is not forcing a branch name change into any existing repositories. It is entirely upto QEMU to decide when to change our branch names. Forks of QEMU also won't get a new branch name, because any branches in forks are inherited from what exists in repository being forked and not arbitrarily renamed.

Oh, then I misunderstood the overall change. Thanks for correcting me.

Quoted 10 lines

So, AFAICT, only brand new (ie empty) repositories will get 'main' as the new default branch name.

IOW, I'd describe this as

"We want to skip the checkpatch and DCO signoff jobs when
pushing to the default branch. Currently this branch is called 'master', but we don't need to hardcode this in the CI configuration, because the $CI_DEFAULT_BRANCH env variable exposes it."

OK, I'll respin, thanks!

Quoted 28 lines
Quoted 14 lines
.gitlab-ci.yml +1 -1
index f718b61fa78..db4e8490483 100644
@@ -784,7 +784,7 @@ check-patch:
   script: .gitlab-ci.d/check-patch.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000
   allow_failure: true

.gitlab-ci.yml check-dco: · line 802

Quoted 7 lines
.gitlab-ci.yml +1 -1
@@ -797,7 +797,7 @@ check-dco:
   script: .gitlab-ci.d/check-dco.py
   except:
     variables:
-      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
+      - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
   variables:
     GIT_DEPTH: 1000

Regards,
Daniel