-
Notifications
You must be signed in to change notification settings - Fork 2
/
commit
executable file
·84 lines (78 loc) · 2.87 KB
/
commit
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -e
cpopt=''
cptest="$(mktemp cptest-XXXXX)"
cptestout="$(mktemp cptestout-XXXXX)"
if cp -l $cptest $cptestout 2>/dev/null; then
cpopt='-l'
fi
rm -f $cptest $cptestout
function commit_branch {
local branch="$1"
local src="$2"
local msg="$3"
local readme="$4"
local tempdir="$(mktemp -d build-XXXXX)"
local commitroot="$tempdir/commitroot"
cp -R $cpopt "$src" "$commitroot"
echo "$readme" > "$commitroot/README"
git add -f "$commitroot/"
local tree="$(git write-tree --prefix="$commitroot/")"
git reset -q -- "$tempdir"
rm -rf "$tempdir"
export GIT_AUTHOR_NAME="$(git log -n 1 --format='%an')"
export GIT_AUTHOR_EMAIL="$(git log -n 1 --format='%ae')"
export GIT_COMMITTER_NAME="Travis CI"
export GIT_COMMITTER_EMAIL="travis-ci@$(hostname -f)"
local parent="$(git rev-parse -q --verify "refs/heads/$branch" || true)"
if [ -z "$parent" ]; then
if git fetch --depth=1 builds "$branch" 2>/dev/null; then
parent="$(git rev-parse FETCH_HEAD)"
fi
fi
if [ -n "$parent" ]; then
parent="-p $parent"
fi
local commit="$(git commit-tree "$tree" $parent -m "$msg")"
git update-ref "refs/heads/$branch" "$commit"
echo "Committed $(git describe --all --long $branch)"
}
full_version="$1"
local_lib="${full_version/*@/}"
perl_version="${full_version/@*/}"
[ "$local_lib" == "$full_version" ] && unset local_lib
helper_ref="$(git --git-dir="$HELPER_ROOT/.git" describe --all --long HEAD)"
ref="$(git describe --all --long HEAD)"
if [ -z "$NO_COMMIT_PERL" ]; then
perlbranch="perl/$perl_version"
commitmessage="Perl $perl_version built for $ref"
git rev-parse --verify -q "$perlbranch" >/dev/null \
&& lastcommit="$(git log --format='%s' -n 1 "$perlbranch")"
if [ "$lastcommit" != "$commitmessage" ]; then
readme="$(
echo "Perl $perl_version built by Travis Helpers: $helper_ref"
echo '------------------------------------------------------------------------------'
"$PERLBREW_ROOT/perls/$perl_version/bin/perl" -v
if [ -e /etc/lsb-release ]; then
echo '------------------------------------------------------------------------------'
cat /etc/lsb-release
fi
)"
commit_branch "$perlbranch" "$PERLBREW_ROOT/perls/$perl_version" "$commitmessage" "$readme"
fi
fi
if [ -n "$local_lib" ]; then
readme="$(
echo "local::lib $local_lib for Perl $perl_version built by Travis Helpers: $helper_ref"
echo '------------------------------------------------------------------------------'
"$PERLBREW_ROOT/perls/$perl_version/bin/perl" -v
if [ -e /etc/lsb-release ]; then
echo '------------------------------------------------------------------------------'
cat /etc/lsb-release
fi
)"
commit_branch "libs/$perl_version/$local_lib" \
"$PERLBREW_HOME/libs/$perl_version@$local_lib" \
"local::lib $local_lib for Perl $perl_version built for $ref" \
"$readme"
fi