Skip to content

Commit 54235a6

Browse files
committed
bors-ng: check linear git history before building
This blocks pull requests if they contain merge commits.
1 parent 0c3efcc commit 54235a6

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.circleci/config.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
version: 2.1
22
jobs:
3+
check-linear:
4+
machine:
5+
image: ubuntu-1604:201903-01
6+
steps:
7+
- checkout
8+
- run:
9+
name: Check git history of branch is linear
10+
command: tools/check-linear.sh
311
build:
412
machine:
513
image: ubuntu-1604:201903-01
@@ -34,8 +42,15 @@ jobs:
3442
command: echo "bazel build //upload --verbose_failures" | HOMEWORLD_CHROOT="$HOME/autobuild-chroot" USER="circleci" ./build-chroot/enter-ci.sh
3543
workflows:
3644
version: 2
37-
build:
45+
workflow:
3846
jobs:
47+
- check-linear:
48+
filters:
49+
branches:
50+
ignore:
51+
- staging
52+
- trying
53+
- master
3954
- build:
4055
filters:
4156
branches:

bors.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ status = [
22
"ci/circleci: build",
33
"continuous-integration/jenkins/branch",
44
]
5+
pr_status = [
6+
"ci/circleci: check-linear",
7+
]
58
required_approvals = 1
69
timeout_sec = 10800 # three hour timeout
710
cut_body_after = "---"

tools/check-linear.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
if [ 0 = "$(git rev-list --min-parents=2 --count "$(git merge-base origin/master HEAD)"..HEAD)" ]
5+
then
6+
echo 'git history is linear'
7+
else
8+
echo 'error: nonlinear branch git history'
9+
echo 'merge commits:'
10+
git rev-list --min-parents=2 "$(git merge-base origin/master HEAD)"..HEAD
11+
exit 1
12+
fi

0 commit comments

Comments
 (0)