diff options
author | Slávek Banko <[email protected]> | 2023-06-05 20:05:55 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2023-06-18 12:49:08 +0200 |
commit | 2c8776b5d98ebc6ee4d7041cb0f761e44d8cd3d8 (patch) | |
tree | c2451a741430837f7f887e5cb9ebc9fe9395b9ba | |
parent | ec0ec3b8bcb6398418dd55d3c3b0603169b6c752 (diff) | |
download | scripts-2c8776b5d98ebc6ee4d7041cb0f761e44d8cd3d8.tar.gz scripts-2c8776b5d98ebc6ee4d7041cb0f761e44d8cd3d8.zip |
create_tarball: Add support for creating tarballs from head on a git tag.r14.1.1
Signed-off-by: Slávek Banko <[email protected]>
(cherry picked from commit 1ccd5c4fa1cc4147464572b463876643e5672008)
-rwxr-xr-x | create_all_tarballs | 20 | ||||
-rwxr-xr-x | create_tarball | 34 |
2 files changed, 41 insertions, 13 deletions
diff --git a/create_all_tarballs b/create_all_tarballs index 1434f77..7caf7bd 100755 --- a/create_all_tarballs +++ b/create_all_tarballs @@ -70,12 +70,18 @@ cd `git rev-parse --show-toplevel` # Check remote branch branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` if [[ -z "$branch" ]]; then - branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + branch_detached=`git branch --contains HEAD | egrep "^\* \(HEAD detached at" | head -n1 | sed "s|^\* (HEAD detached at \([^)]*\)).*$|\1|"` + branch=`git tag | grep -Fx "${branch_detached}"` +fi +if [[ -z "$branch" ]]; then + branch=`git branch -r --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + branch=${branch#origin/} fi if [[ -z "$branch" ]] || - [[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then - echo "There is not active upstream branch. Exiting..." - exit 1 + ( [[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]] && + [[ -z "`git tag | grep -Fx \"${branch}\"`" ]] ); then + echo "There is not active upstream branch. Exiting." + exit 1 fi # Set target version @@ -106,12 +112,18 @@ if [ "$TARGET" != "${TARGET#3.5.}" ]; then else targetBranch=master fi + if [ "$branch" = "v${TARGET}" ]; then + targetBranch=v${TARGET} + fi else if [ "$TARGET" != "${TARGET%.0}" ]; then targetBranch=master else targetBranch=r${TARGET%.*}.x fi + if [ "$branch" = "r${TARGET}" ]; then + targetBranch=r${TARGET} + fi fi if [ "$branch" != "$targetBranch" ]; then echo "Target $TARGET is not valid on $branch branch. Exiting." diff --git a/create_tarball b/create_tarball index 6bc534e..af991b0 100755 --- a/create_tarball +++ b/create_tarball @@ -30,12 +30,18 @@ fi # Check remote branch branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` if [[ -z "$branch" ]]; then - branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + branch_detached=`git branch --contains HEAD | egrep "^\* \(HEAD detached at" | head -n1 | sed "s|^\* (HEAD detached at \([^)]*\)).*$|\1|"` + branch=`git tag | grep -Fx "${branch_detached}"` +fi +if [[ -z "$branch" ]]; then + branch=`git branch -r --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + branch=${branch#origin/} fi if [[ -z "$branch" ]] || - [[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then - echo "There is not active upstream branch. Exiting..." - exit 1 + ( [[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]] && + [[ -z "`git tag | grep -Fx \"${branch}\"`" ]] ); then + echo "There is not active upstream branch. Exiting." + exit 1 fi # Get submodule name @@ -82,12 +88,18 @@ if [ "$TARGET" != "${TARGET#3.5.}" ]; then else targetBranch=master fi + if [ "$branch" = "v${TARGET}" ]; then + targetBranch=v${TARGET} + fi else if [ "$TARGET" != "${TARGET%.0}" ]; then targetBranch=master else targetBranch=r${TARGET%.*}.x fi + if [ "$branch" = "r${TARGET}" ]; then + targetBranch=r${TARGET} + fi fi if [ "$branch" != "$targetBranch" ]; then echo "Target $TARGET is not valid on $branch branch. Exiting." @@ -128,11 +140,15 @@ if [[ -n "$target_tag" ]] && \ fi # Calculate version -tag=`git tag | \ - sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ - while read t; do \ - git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ - echo "$t..HEAD" && break; done` +if [[ -z "$target_tag" ]]; then + tag=`git tag | \ + sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \ + while read t; do \ + git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ + echo "$t..HEAD" && break; done` +else + tag="$target_tag..HEAD" +fi count=`git log $tag --pretty=oneline | wc -l` |