-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump.sh
executable file
·66 lines (57 loc) · 1.99 KB
/
bump.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -o errexit
set -o xtrace
osa_url="https://github.com/openstack/openstack-ansible.git"
# Add openstack's gerrit ssh public key
# Known public key
gerrit_pubkey="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCfsIj/jqpI+2CFdjCL6kOiqdORWvxQ2sQbCzSzzmLXic8yVhCCbwarkvEpfUOHG4eyB0vqVZfMffxf0Yy3qjURrsroBCiuJ8GdiAcGdfYwHNfBI0cR6kydBZL537YDasIk0Z3ILzhwf7474LmkVzS7V2tMTb4ZiBS/jUeiHsVp88FZhIBkyhlb/awAGcUxT5U4QBXCAmerYXeB47FPuz9JFOVyF08LzH9JRe9tfXtqaCNhlSdRe/2pPRvn2EIhn5uHWwATACG9MBdrK8xv8LqPOik2w1JkgLWyBj11vDd5I3IjrmREGw8dqImqp0r6MD8rxqADlc1elfDIXYsy+TVH"
# Found public key (for comparison purposes, avoiding mitm)
gerrit_scan=$(ssh-keyscan -t rsa -p 29418 review.opendev.org 2>/dev/null)
gerrit_found_pubkey=$(echo ${gerrit_scan} | cut -d ' ' -f '2,3')
if [[ ${gerrit_pubkey} != ${gerrit_found_pubkey} ]]; then
echo "Alert! MITM detected"
exit 1
else
echo "Good key found, can ssh in"
echo ${gerrit_scan} >> ~/.ssh/known_hosts
fi
# Backup gitconfig if it exists already
if [[ -f ~/.gitconfig ]]; then
cp ~/.gitconfig ~/.gitconfig.old
fi
# Override gitconfig
cat > ~/.gitconfig << EOF
[gitreview]
username = noonedeadpunk
[user]
name = Dmitriy Rabotyagov
email = [email protected]
EOF
branch="$1"
if [[ "$branch" == "master" ]]; then
gitbranchname="master"
else
gitbranchname="stable/${branch}"
fi
git clone $osa_url "osa-$branch"
echo "Bump SHAs for $gitbranchname" > "commitmsg-$branch"
pushd "osa-$branch"
git checkout "$gitbranchname"
git pull
git checkout -b bump_osa_requirements
osa releases bump_upstream_shas
osa releases bump_roles "$gitbranchname"
git status
git diff
git add .
git commit -F "../commitmsg-$branch"
osa releases check_pins
# Bumping only every second Monday
if [[ $(( $(date +'%V') % 2)) -eq 0 ]]; then
echo "Even week number, bumping!"
if [[ $(( $(date +'%w') % 7)) -eq 0 ]]; then
# Sundays! Bumping enabled!
git review -f -t bump_osa
fi
fi
popd