Skip to content

Commit ce1c9a9

Browse files
committed
Update dependencies-update scripts
The scripts are changed so that the update happens in the current branch, and the changes are not pushed to the repository. Setting the branch and pushing the changes will be the responsibility of the tekton pipeline.
1 parent 881aea5 commit ce1c9a9

File tree

4 files changed

+24
-47
lines changed

4 files changed

+24
-47
lines changed

developer/images/dependencies-update/hack/bin/task.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ task_init() {
2828
}
2929

3030
task_end() {
31-
if [ -n "$BRANCH_NAME" ]; then
32-
commit_changes
33-
fi
34-
}
35-
36-
commit_changes() {
37-
if ! git diff --quiet HEAD; then
31+
# Commit_changes
32+
if ! git diff --quiet; then
3833
git add .
3934
git commit --file="$COMMIT_MSG" --quiet --signoff
4035
fi

developer/images/dependencies-update/hack/bin/tasks/update_binaries.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,24 @@ run_task() {
3737
for BINARY in "${BINARIES[@]}"; do
3838
update_binary
3939
done
40-
git diff shared/config/dependencies.sh \
41-
| grep "^+export" \
42-
| sed -e "s:^+export:-:" -e "s:_VERSION=: to :" \
43-
| tr -d \" \
44-
| tr "[:upper:]" "[:lower:]" >>"$COMMIT_MSG"
40+
if [ $(git diff shared/config/dependencies.sh | wc -l) != "0" ]; then
41+
git diff shared/config/dependencies.sh \
42+
| grep "^+export" \
43+
| sed -e "s:^+export:-:" -e "s:_VERSION=: to :" \
44+
| tr -d \" \
45+
| tr "[:upper:]" "[:lower:]" >>"$COMMIT_MSG"
46+
fi
4547
}
4648

4749
update_binary() {
4850
if grep --ignore-case --quiet " ${BINARY}_VERSION=.*# *Freeze" "$DEPENDENCIES"; then
4951
# Ignore frozen dependencies
5052
return
5153
fi
52-
echo "$BINARY"
54+
echo -n " - $BINARY: "
5355
unset VERSION
5456
"get_${BINARY}_version"
57+
echo "$VERSION"
5558
BINARY=$(echo "$BINARY" | tr "[:lower:]" "[:upper:]")
5659
sed -i -e "s:\( ${BINARY}_VERSION\)=.*:\1=\"$VERSION\":" "$DEPENDENCIES"
5760
}
@@ -147,7 +150,6 @@ get_github_release() {
147150
| sort -V \
148151
| tail -1
149152
)
150-
echo "VERSION=$VERSION"
151153
}
152154

153155
if [ "${BASH_SOURCE[0]}" == "$0" ]; then

developer/images/dependencies-update/hack/bin/tasks/update_dockerfiles_base_images_sha.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ process_dockerfiles() {
4444

4545
process_base_image_cmd() {
4646
base_image_name=$(echo "$from_base_image" | sed 's:^.* ::')
47-
echo -n "- $base_image_name"
47+
echo -n " - $base_image_name"
4848
get_base_image_sha
4949
echo -n "@$base_image_sha : "
5050
update_base_image_sha

developer/images/dependencies-update/hack/bin/update.sh

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ Usage:
3636
Upgrade Pipeline Service dependencies.
3737
3838
Optional arguments:
39-
-c, --commit_to BRANCH_NAME
40-
Commit changes to BRANCH_NAME
41-
Default: robot/\$CURRENT_BRANCH_NAME/update_dependencies.
4239
-t, --task TASKNAME
4340
Only run the selected task. Can be repeated to run multiple tasks.
4441
TASKNAME must be in [$(echo "${DEFAULT_TASKS[@]}" | sed 's: :, :')].
@@ -57,15 +54,11 @@ Example:
5754
}
5855

5956
parse_args() {
60-
mapfile -t DEFAULT_TASKS < <(find "$SCRIPT_DIR/tasks" -type f -name \*.sh -exec basename {} \; | sed 's:...$::')
57+
mapfile -t DEFAULT_TASKS < <(find "$SCRIPT_DIR/tasks" -type f -name \*.sh -exec basename {} \; | sort | sed 's:...$::')
6158
TASKS=()
6259
WORKSPACE_DIR="$PROJECT_DIR"
6360
while [[ $# -gt 0 ]]; do
6461
case $1 in
65-
-c | --commit_to)
66-
shift
67-
BRANCH_NAME="$1"
68-
;;
6962
-t | --task)
7063
shift
7164
TASKS+=("$1")
@@ -98,53 +91,40 @@ init() {
9891
TASKS=( "${DEFAULT_TASKS[@]}" )
9992
fi
10093
COMMIT_MSG="${TMPDIR:-/tmp}/update_commit_msg.txt"
101-
export BRANCH_NAME
10294
export COMMIT_MSG
10395
export WORKSPACE_DIR
10496
cd "$WORKSPACE_DIR"
10597
git config --global --add safe.directory "$PWD"
10698
}
10799

108100
prepare_branch(){
109-
CURRENT_BRANCH_NAME=$(git branch --show-current)
110-
BRANCH_NAME=${BRANCH_NAME:-robot/$CURRENT_BRANCH_NAME/update_dependencies}
111-
112101
# Revert any change to the current branch
113102
if ! git diff --quiet; then
114103
git stash --include-untracked
115104
GIT_STASH="true"
116105
fi
117106
GIT_STASH=${GIT_STASH:-}
118-
119-
# Create a new branch from the current branch
120-
git branch --copy --force "$BRANCH_NAME"
121-
git checkout "$BRANCH_NAME"
107+
START_COMMIT=$(git rev-parse HEAD)
122108
}
123109

124-
push_changes(){
125-
local push="false"
126-
if ! git diff --quiet "$CURRENT_BRANCH_NAME"; then
127-
if ! git fetch origin "refs/heads/$BRANCH_NAME" 2>/dev/null; then
128-
push="true"
129-
elif ! git diff --quiet "origin/$BRANCH_NAME"; then
130-
push="true"
131-
fi
110+
show_summary(){
111+
local updated="false"
112+
if ! git diff --quiet $START_COMMIT..HEAD; then
113+
updated="true"
132114
fi
133115

134116
echo
135117
echo "[Summary]"
136-
if [ "$push" = "true" ]; then
137-
git log --format="%B" "$CURRENT_BRANCH_NAME..HEAD"
138-
git push --force --quiet --set-upstream "origin" "$BRANCH_NAME"
118+
if [ "$updated" = "true" ]; then
119+
git log --format="%B" "$START_COMMIT..HEAD"
139120
else
140-
echo "No update to push"
121+
echo "No updates"
141122
fi
142123
}
143124

144-
revert_to_current_branch(){
125+
revert_branch(){
145126
echo
146127
git clean --force -x
147-
git checkout --force "$CURRENT_BRANCH_NAME"
148128
if [ -n "$GIT_STASH" ]; then
149129
git stash pop
150130
fi
@@ -163,8 +143,8 @@ main() {
163143
echo "[$task_name]"
164144
"$SCRIPT_DIR/tasks/$task_name.sh"
165145
done
166-
push_changes
167-
revert_to_current_branch
146+
show_summary
147+
revert_branch
168148
}
169149

170150
if [ "${BASH_SOURCE[0]}" == "$0" ]; then

0 commit comments

Comments
 (0)