[java-parent-project] branch master updated: GEN-264 - Add scripts to rename HEAD branch to main

Ian Young ian at iay.org.uk
Tue Aug 11 12:36:46 UTC 2020


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch master
in repository java-parent-project.

View the commit online:
http://git.shibboleth.net/view/?p=java-parent-project.git;a=commit;h=27b5c32d1971aeccb32be77c13abd996c448ac97

The following commit(s) were added to refs/heads/master by this push:
       new  27b5c32   GEN-264 - Add scripts to rename HEAD branch to main
27b5c32 is described below

commit 27b5c32d1971aeccb32be77c13abd996c448ac97
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Tue Aug 11 13:36:12 2020 +0100

    GEN-264 - Add scripts to rename HEAD branch to main
    
    https://issues.shibboleth.net/jira/browse/GEN-264
---
 resources/git/follow-main    | 65 ++++++++++++++++++++++++++++++++++++++++
 resources/git/rename-to-main | 70 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+)

diff --git a/resources/git/follow-main b/resources/git/follow-main
new file mode 100755
index 0000000..9d69fff
--- /dev/null
+++ b/resources/git/follow-main
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+#
+# This script performs the operations required to move a local
+# repository's HEAD branch from "master" to "main".
+#
+# See: https://issues.shibboleth.net/jira/browse/GEN-264
+#
+# This should be run by the owner of a clone of the repository
+# in Gitolite to follow the change, not to initiate it.
+#
+
+#
+# Exit on a failed command.
+#
+set -e
+
+#
+# Figure out name of repository.
+#
+REPO=$(basename -- `pwd`)
+
+#
+# We must be in a repository.
+#
+if [ ! -d .git ]; then
+  echo "Not in a git repository!"
+  exit 1
+fi
+
+#
+# We must have a "master" branch to rename.
+#
+if ! git show-ref --quiet refs/heads/master ; then
+  echo "master branch does not exist; repository already converted?"
+  exit 1
+fi
+
+#
+# We must not already have a "main" branch or rename will fail.
+#
+if git show-ref --quiet refs/heads/main ; then
+  echo "main branch already exists; repository already converted?"
+  exit 1;
+fi
+
+#
+# The actual migration starts here.
+#
+
+echo "Pruning remote refs..."
+git fetch --prune origin
+
+echo "Checking out main branch..."
+git checkout main
+
+echo "Setting remote HEAD for origin remote..."
+git remote set-head origin -a
+
+echo "Deleting local master branch..."
+git branch -d master
+
+#
+# End.
+#
diff --git a/resources/git/rename-to-main b/resources/git/rename-to-main
new file mode 100755
index 0000000..730f869
--- /dev/null
+++ b/resources/git/rename-to-main
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+#
+# This script performs the operations required to rename a repository's
+# HEAD branch from "master" to "main".
+#
+# See: https://issues.shibboleth.net/jira/browse/GEN-264
+#
+# It should only be run by a Gitolite administrator.
+#
+
+#
+# Exit on a failed command.
+#
+set -e
+
+#
+# Figure out name of repository.
+#
+REPO=$(basename -- `pwd`)
+
+#
+# We must be in a repository.
+#
+if [ ! -d .git ]; then
+  echo "Not in a git repository!"
+  exit 1
+fi
+
+#
+# We must have a "master" branch to rename.
+#
+if ! git show-ref --quiet refs/heads/master ; then
+  echo "master branch does not exist; repository already converted?"
+  exit 1
+fi
+
+#
+# We must not already have a "main" branch or rename will fail.
+#
+if git show-ref --quiet refs/heads/main ; then
+  echo "main branch already exists; repository already converted?"
+  exit 1;
+fi
+
+#
+# The actual migration starts here.
+#
+
+echo "Renaming local master to main..."
+git branch -m master main
+
+echo "Pushing new main branch..."
+git push -u origin main
+
+echo "Setting HEAD on Gitolite server..."
+ssh git at git.shibboleth.net symbolic-ref ${REPO} HEAD refs/heads/main
+
+echo "Deleting remote master branch..."
+git push origin --delete master
+
+echo "Pruning remote refs..."
+git fetch --prune origin
+
+echo "Setting remote HEAD for origin remote..."
+git remote set-head origin -a
+
+#
+# End.
+#

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list