@@ -7,7 +7,8 @@ DRY_RUN=$3
7
7
LOCAL_PATH=$( dirname " $( realpath " $0 " ) " ) /..
8
8
9
9
# load variables
10
- source ${LOCAL_PATH} /assets/set_variables.sh
10
+ # shellcheck source=./assets/set_variables.sh
11
+ source " ${LOCAL_PATH} /assets/set_variables.sh"
11
12
12
13
13
14
function usage {
@@ -56,7 +57,7 @@ msg "Version to add: $ADD_VERSION"
56
57
57
58
# TODO: here check we're in a Pongo git repo, and on 'master' branch
58
59
59
- if $( version_exists $ADD_VERSION ) ; then
60
+ if version_exists " $ADD_VERSION " ; then
60
61
err " Version '$ADD_VERSION ' is already available"
61
62
exit 1
62
63
fi
@@ -68,26 +69,27 @@ if [[ ! -f $VERSIONS_FILE ]]; then
68
69
fi
69
70
70
71
# add the version to the file
71
- echo " $ADD_VERSION " >> $VERSIONS_FILE
72
- sort --version-sort $VERSIONS_FILE > ${VERSIONS_FILE} _tmp
72
+ echo " $ADD_VERSION " >> " $VERSIONS_FILE "
73
+ sort --version-sort " $VERSIONS_FILE " > " ${VERSIONS_FILE} _tmp"
73
74
74
- if [[ ! -f ${VERSIONS_FILE} _tmp ]]; then
75
+ if [[ ! -f " ${VERSIONS_FILE} _tmp" ]]; then
75
76
err " Failed to add and sort the new versions file"
76
77
exit 1
77
78
fi
78
79
79
- mv ${VERSIONS_FILE} _tmp $VERSIONS_FILE
80
+ mv " ${VERSIONS_FILE} _tmp" " $VERSIONS_FILE "
80
81
81
82
# reload variables to add the new version to our array
82
- source ${LOCAL_PATH} /assets/set_variables.sh
83
+ # shellcheck source=./assets/set_variables.sh
84
+ source " ${LOCAL_PATH} /assets/set_variables.sh"
83
85
84
86
# add the first commit with just the added version
85
- pushd ${LOCAL_PATH} > /dev/null
87
+ pushd " ${LOCAL_PATH} " > /dev/null || { echo " Failure to enter $LOCAL_PATH " ; exit 1 ; }
86
88
PREVIOUS_BRANCH=$( git rev-parse --abbrev-ref HEAD)
87
89
BRANCH_NAME=add-version-${ADD_VERSION}
88
- git checkout -b ${BRANCH_NAME}
90
+ git checkout -b " ${BRANCH_NAME} "
89
91
90
- git add $VERSIONS_FILE
92
+ git add " $VERSIONS_FILE "
91
93
92
94
if [[ " $CODE_BASE " == " CE" ]]; then
93
95
git commit --message=" feat(version) added Kong open source version $ADD_VERSION "
96
98
fi
97
99
98
100
# add the artifacts and the second commit
99
- source ${LOCAL_PATH} /assets/update_versions.sh
101
+ # shellcheck source=./assets/update_versions.sh
102
+ source " ${LOCAL_PATH} /assets/update_versions.sh"
100
103
update_artifacts
101
104
102
105
if [[ ! " $? " == " 99" ]]; then
103
106
warn " Nothing was updated? nothing to commit. Please check the version"
104
107
warn " you have added to be a valid one."
105
- git checkout $PREVIOUS_BRANCH & > /dev/null
106
- git branch -D $BRANCH_NAME & > /dev/null
108
+ git checkout " $PREVIOUS_BRANCH " & > /dev/null
109
+ git branch -D " $BRANCH_NAME " & > /dev/null
107
110
exit 1
108
111
fi
109
112
117
120
118
121
# push to remote and create a PR
119
122
if [[ " $DRY_RUN " == " " ]]; then
120
- git push --set-upstream origin $BRANCH_NAME
123
+ git push --set-upstream origin " $BRANCH_NAME "
121
124
if [[ ! $? -eq 0 ]]; then
122
- git checkout $PREVIOUS_BRANCH & > /dev/null
125
+ git checkout " $PREVIOUS_BRANCH " & > /dev/null
123
126
err " Failed to push the branch '$BRANCH_NAME ' to the remote git repo"
124
127
fi
125
128
else
@@ -129,8 +132,8 @@ msg "Now creating a Github pull-request:"
129
132
if [[ " $DRY_RUN " == " " ]]; then
130
133
hub pull-request --no-edit
131
134
if [[ ! $? -eq 0 ]]; then
132
- git checkout $PREVIOUS_BRANCH & > /dev/null
133
- git branch -D $BRANCH_NAME & > /dev/null
135
+ git checkout " $PREVIOUS_BRANCH " & > /dev/null
136
+ git branch -D " $BRANCH_NAME " & > /dev/null
134
137
err " Failed to create a PR from the '$BRANCH_NAME ' branch"
135
138
fi
136
139
else
@@ -141,8 +144,8 @@ msg "Success! A new branch '$BRANCH_NAME' was pushed to the repo (and a PR creat
141
144
msg " with the following commits:"
142
145
git log --oneline -2
143
146
echo
144
- git checkout $PREVIOUS_BRANCH & > /dev/null
145
- git branch -D $BRANCH_NAME & > /dev/null
147
+ git checkout " $PREVIOUS_BRANCH " & > /dev/null
148
+ git branch -D " $BRANCH_NAME " & > /dev/null
146
149
msg " done. Goto https://github.com/kong/kong-pongo/pulls to checkout the new PR."
147
150
if [[ ! " $DRY_RUN " == " " ]]; then
148
151
warn " test-run completed, nothing was written! re-run without 'test' to push the changes."
0 commit comments