Skip to content

Commit f61fe16

Browse files
committed
Generalize main branch logic
1 parent 8c862b4 commit f61fe16

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

check-branch.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
# recording whether the build passes or fails for each.
55

66
commits=$@
7-
test "$commits" || commits=$(git rev-list HEAD ^master | sed '1!G;h;$!d')
7+
8+
remote=$(git rev-parse --symbolic-full-name HEAD@{u})
9+
remote=${remote%/*}
10+
remote=${remote#refs/remotes/}
11+
headBranch=$(git remote show "$remote" | grep HEAD | sed 's/ *HEAD branch: //')
12+
13+
test "$commits" || commits=$(git rev-list HEAD "^$headBranch" | sed '1!G;h;$!d')
814
# NB: The sed line above reverses the order of the commits.
915
# See: http://stackoverflow.com/a/744093
1016

github-actionify.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ EOL
203203
# Add/update the GitHub Action setup script.
204204
cat >"$tmpFile" <<EOL
205205
#!/bin/sh
206-
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/master/ci-setup-github-actions.sh
206+
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-setup-github-actions.sh
207207
sh ci-setup-github-actions.sh
208208
EOL
209209
chmod +x "$tmpFile"
@@ -212,7 +212,7 @@ EOL
212212
# Add/update the GitHub Action build script.
213213
cat >"$tmpFile" <<EOL
214214
#!/bin/sh
215-
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/master/ci-build.sh
215+
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-build.sh
216216
sh ci-build.sh
217217
EOL
218218
chmod +x "$tmpFile"

remote-branch-info.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ esac
2424

2525
for ref in $(git for-each-ref refs/remotes/$remote --format='%(refname)')
2626
do
27-
27+
headBranch=$(git remote show "$remote" | grep HEAD | sed 's/ *HEAD branch: //')
2828
refname=${ref#refs/remotes/$remote/}
29-
case "$refname" in contrib|master) continue;; esac
30-
unmerged_count=$(git cherry master $ref | grep '^+' | wc -l)
31-
info=$(git log -n 1 --format='%an - %ar' $ref)
32-
echo $refname - $info - $unmerged_count unmerged
33-
done
29+
test "$refname" = "$headBranch" -o "$refname" = HEAD && continue
30+
unmerged_count=$(git cherry "$headBranch" "$ref" | grep '^+' | wc -l)
31+
author=$(git log -n 1 --format='%an' "$ref")
32+
timestamp=$(git log -n 1 --format='%ar' "$ref")
33+
echo "$refname~$author~$timestamp~$unmerged_count unmerged"
34+
done | column -t -s '~'

0 commit comments

Comments
 (0)