Browse Source

Merge "Add --dry-run to branch-stx"

Zuul 8 months ago
parent
commit
a57fa7a1b8
1 changed files with 44 additions and 26 deletions
  1. 44
    26
      release/branch-stx.sh

+ 44
- 26
release/branch-stx.sh View File

@@ -1,7 +1,7 @@
1 1
 #!/bin/bash
2 2
 # branch-stx.sh - create STX branches based on today
3 3
 #
4
-# branch-stx.sh [<manifest>]
4
+# branch-stx.sh [--dry-run] [<manifest>]
5 5
 #
6 6
 # * get the repo list from stx-manifest in both starlingx and stx-staging remotes
7 7
 # * create a new branch
@@ -21,6 +21,12 @@
21 21
 
22 22
 set -e
23 23
 
24
+# Grab options
25
+if [[ "$1" == "--dry-run" ]]; then
26
+    DRY_RUN=1
27
+    shift;
28
+fi
29
+
24 30
 # Where to get the repo list
25 31
 MANIFEST=${1:-default.xml}
26 32
 
@@ -53,15 +59,20 @@ defaultbranch=$branch"
53 59
     git add .gitreview
54 60
     git commit -s -m "Update .gitreview for $branch"
55 61
     git show
56
-    git review -t "create-${branch}"
62
+    if [[ -z $DRY_RUN ]]; then
63
+        git review -t "create-${branch}"
64
+    else
65
+        echo "### skipping review submission to $branch"
66
+    fi
57 67
 }
58 68
 
59
-# branch_repo <repo-uri> <sha> <branch-base>
69
+# branch_repo <remote> <repo-uri> <sha> <branch-base>
60 70
 function branch_repo {
61
-    local repo=$1
62
-    local sha=$2
63
-    local branch=$3
64
-    local tag=$4
71
+    local remote=$1
72
+    local repo=$2
73
+    local sha=$3
74
+    local branch=$4
75
+    local tag=$5
65 76
 
66 77
     local repo_dir=${repo##*/}
67 78
 
@@ -80,6 +91,31 @@ function branch_repo {
80 91
     # tag branch point at $sha
81 92
     git tag -f $tag $sha
82 93
 
94
+    # Push the new goodness back up
95
+    if [[ "$r" == "starlingx" ]]; then
96
+        # Do the Gerrit way
97
+
98
+        # set up gerrit remote
99
+        git review -s
100
+
101
+        # push
102
+        if [[ -z $DRY_RUN ]]; then
103
+            git push gerrit $branch
104
+        else
105
+            echo "### skipping push to $branch"
106
+        fi
107
+
108
+        update_gitreview $branch
109
+    else
110
+        # Do the Github way
111
+        # push
112
+        if [[ -z $DRY_RUN ]]; then
113
+            git push --tags -u origin $branch
114
+        else
115
+            echo "### skipping push to $branch"
116
+        fi
117
+    fi
118
+
83 119
     cd -
84 120
 }
85 121
 
@@ -88,24 +124,6 @@ for r in $REMOTES; do
88 124
     # crap, convert github URLs to git:
89 125
     repos=$(sed -e 's|https://github.com/starlingx-staging|git@github.com:starlingx-staging|g' <<<$repos)
90 126
     for i in $repos; do
91
-        branch_repo $i HEAD $BRANCH $TAG
92
-        repo_dir=${i##*/}
93
-        cd $repo_dir
94
-        if [[ "$r" == "starlingx" ]]; then
95
-            # Do the Gerrit way
96
-
97
-            # set up gerrit remote
98
-            git review -s
99
-
100
-            # push
101
-            git push gerrit $BRANCH
102
-
103
-            update_gitreview $BRANCH
104
-        else
105
-            # Do the Github way
106
-            # push
107
-            git push --tags -u origin $BRANCH
108
-        fi
109
-        cd -
127
+        branch_repo $r $i HEAD $BRANCH $TAG
110 128
     done
111 129
 done

Loading…
Cancel
Save