File: earliest-commit.sh

package info (click to toggle)
libreswan 4.3-1%2Bdeb11u4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 62,688 kB
  • sloc: ansic: 108,293; sh: 25,973; xml: 11,756; python: 10,230; makefile: 1,580; javascript: 1,353; yacc: 825; sed: 647; perl: 584; lex: 159; awk: 156
file content (56 lines) | stat: -rwxr-xr-x 1,419 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

if test $# -lt 1 ; then
    cat >>/dev/stderr <<EOF

Usage:

    $0 <summarydir> [ <repodir> ]

Identify the git revision of the earliest test result (based on commit
rank) in <summarydir>.

If there are no test results, use <repodir>'s HEAD.

EOF
    exit 1
fi

# paths need to be absolute as potentially cd'ing to $repodir
webdir=$(cd $(dirname $0) && pwd)
summarydir=$(cd $1 && pwd) ; shift

if test $# -gt 0 ; then
    cd $1
    shift
fi

# Create a list of the earliest hashes.  Use xargs to keep the length
# under control.
#
# Most likely this is just one hash, but as results get bigger you
# never know.

hashes=$(ls ${summarydir} \
	    | xargs --no-run-if-empty \
		    ${webdir}/gime-git-rev.sh \
	    | xargs --no-run-if-empty \
		    git show --ignore-missing --no-patch --format=%h \
	    | xargs --no-run-if-empty \
		    git merge-base --octopus )
if test -z "${hashes}" ; then
    hash=$(git show --no-patch --format=%h HEAD)
    echo "No results in ${summarydir} using HEAD ${hash}" 1>&2
    echo $hash
    exit 0
fi

# determine the first of them; need to pretty print the result (git
# merge-base doesn't handle --format).
#
# Assume that ${hashes} isn't so long that more than two iterations of
# merge-base are needed.  If that turns out to be false then "fixing"
# merge-base to take stdin would be better.

git show --no-patch --format=%h \
    $(git merge-base --octopus ${hashes})