[Asterisk-code-review] build: Refactor the earlier "basebranch" thing (asterisk[16])

George Joseph asteriskteam at digium.com
Thu Feb 17 10:38:06 CST 2022


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18017 )


Change subject: build: Refactor the earlier "basebranch" thing
......................................................................

build: Refactor the earlier "basebranch" thing

The earlier attempt at adding a "basebranch" variable to
.gitreview didn't work out too well in practice because changes
were made to .gitreview, which it a checked-in file.  So, if
you wanted to rebase your work branch on the base branch, rebase
would attempt to overwrite your .gitreview with the one from
the base branch and complain about a conflict.

This is a slighltly different approach.  Instead of storing
the basebranch in .gitreview, it can now be stored in a
non-checked-in .develvars file and keyed by the current branch.

So, if you were working on development/16/something and wanted
to push to that branch in gerrit but wanted to pull the external
modules for 16, you'd create the following .develvars file:

[branch "development/16/something"]
    mainline-branch = 16

Of course you could have other things in there as well...

[branch "development/18/something"]
    mainline-branch = 18

[branch "development/19/something_new"]
    mainline-branch = 19

The key is that the .develvars file is NEVER checked in (it's been
added to .gitignore).

This commit also removes the "basebranch" entry that was added by
the earlier commit from the .gitreview file.

Change-Id: I1cdeeaa0944bba3f2e01d7a2039559d0c266f8c9
---
M .gitignore
M .gitreview
M build_tools/make_version
3 files changed, 8 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/17/18017/1

diff --git a/.gitignore b/.gitignore
index 0f31820..1ba75fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,4 +37,4 @@
 out/
 *.orig
 tests/CI/output
-
+.develvars
diff --git a/.gitreview b/.gitreview
index a233c59..a57dca7 100644
--- a/.gitreview
+++ b/.gitreview
@@ -1,6 +1,5 @@
 [gerrit]
 defaultbranch=16
-basebranch=16
 #
 # Intentional padding to ensure it is possible to point a commit
 # to an alternative gerrit server/repository without breaking
diff --git a/build_tools/make_version b/build_tools/make_version
index aefe6b1..f19cb94 100755
--- a/build_tools/make_version
+++ b/build_tools/make_version
@@ -100,7 +100,13 @@
     MODIFIED=""
     SVN_REV=`${GIT} log --pretty=full -1 | sed -n '/git-svn-id:/ s/.*\@\([^ ]*\) .*/\1/p'`
     if [ -z "$SVN_REV" ]; then
-        MAINLINE_BRANCH=$(${GIT} config -f .gitreview --get gerrit.basebranch)
+        # Try to retrieve MAINLINE_BRANCH from a local .develvars file first.
+        # .develvars is keyed by the branch name so we need to get that first.
+        BRANCH=$(${GIT} symbolic-ref --short HEAD)
+        if [ -f .develvars ] ; then
+            MAINLINE_BRANCH=$(${GIT} config -f .develvars --get branch.${BRANCH}.mainline-branch)
+        fi
+        # If we didn't find it, get it from .gitreview defaultbranch.
         if [ "x${MAINLINE_BRANCH}" = "x" ] ; then
             MAINLINE_BRANCH=$(${GIT} config -f .gitreview --get gerrit.defaultbranch)
         fi

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18017
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I1cdeeaa0944bba3f2e01d7a2039559d0c266f8c9
Gerrit-Change-Number: 18017
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220217/e0f1646d/attachment-0001.html>


More information about the asterisk-code-review mailing list