-
Notifications
You must be signed in to change notification settings - Fork 1
/
ref-update
executable file
·53 lines (42 loc) · 1.13 KB
/
ref-update
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
#!/bin/bash
# This script implements a gerrit hook to refresh our local gerrit repository with the
# origin one from github.
set -e # exit on any error return val
# --project <project name> --refname <refname> --uploader <uploader> --oldrev <sha1> --newrev <sha1>
while [[ $# > 1 ]] ; do
case "$1" in
--change)
change=$2 ; shift ;;
--change-url)
change_url=$2 ; shift ;;
--change-owner)
change_owner=$2 ; shift ;;
--project)
project=$2 ; shift ;;
--branch)
branch=$2 ; shift ;;
--submitter)
submitter=$2 ; shift ;;
--commit)
commit=$2 ; shift ;;
--refname)
refname=$2 ; shift ;;
--uploader)
uploader=$2 ; shift ;;
--oldrev)
oldrev=$2 ; shift ;;
--newrev)
newrev=$2 ; shift ;;
esac
shift
done
branch=$(echo "$refname" | sed "s-refs/for/--")
set +e
grep "$project" /home/gerrit/gerrit/etc/non_gitlab_repos.txt
exclude_proj=$?
set -e
if [[ $exclude_proj != 0 ]] ; then
echo "Ensuring gerrit in sync with github on branch $branch."
git fetch origin $branch
git update-ref refs/heads/$branch FETCH_HEAD
fi