summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-09-25 13:14:27 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-09-25 16:01:57 +0200
commit59ce58e1443c445ef1a85efac6c337d97fb80961 (patch)
treeafb9b884d1fb44fb2a1b2b19465aaa8e71ff8054
parentdd095e2c17aa8a9e90803d7d957706739fd08ca6 (diff)
downloadqtlocation-mapboxgl-upstream/backport-12958-to-espresso.tar.gz
[build] compare clang-tidy with merge base instead of masterupstream/backport-12958-to-espresso
-rw-r--r--circle.yml3
-rwxr-xr-xscripts/clang-tools.sh5
-rwxr-xr-xscripts/environment.js5
3 files changed, 5 insertions, 8 deletions
diff --git a/circle.yml b/circle.yml
index 32490c0bf3..20aec84eb4 100644
--- a/circle.yml
+++ b/circle.yml
@@ -347,9 +347,6 @@ jobs:
- *restore-ccache
- *reset-ccache-stats
- run:
- name: Fetch 'origin/master' branch
- command: git fetch origin master:refs/remotes/origin/master
- - run:
name: Generate compilation database
command: make compdb
- run:
diff --git a/scripts/clang-tools.sh b/scripts/clang-tools.sh
index bdda4544b9..735c758d64 100755
--- a/scripts/clang-tools.sh
+++ b/scripts/clang-tools.sh
@@ -2,6 +2,7 @@
set -e
set -o pipefail
+set -u
CLANG_TIDY_PREFIX=${CLANG_TIDY_PREFIX:-$(scripts/mason.sh PREFIX clang-tidy VERSION 4.0.1)}
CLANG_TIDY=${CLANG_TIDY:-${CLANG_TIDY_PREFIX}/bin/clang-tidy}
@@ -33,7 +34,7 @@ function run_clang_tidy() {
}
function run_clang_tidy_diff() {
- OUTPUT=$(git diff origin/master --src-prefix=${CDUP} --dst-prefix=${CDUP} | \
+ OUTPUT=$(git diff ${CIRCLE_MERGE_BASE} --src-prefix=${CDUP} --dst-prefix=${CDUP} | \
${CLANG_TIDY_PREFIX}/share/clang-tidy-diff.py \
-clang-tidy-binary ${CLANG_TIDY} \
2>/dev/null)
@@ -45,7 +46,7 @@ function run_clang_tidy_diff() {
function run_clang_format() {
echo "Running clang-format on $0..."
- DIFF_FILES=$(git diff origin/master --name-only *cpp)
+ DIFF_FILES=$(git diff ${CIRCLE_MERGE_BASE} --name-only *cpp)
echo "${DIFF_FILES}" | xargs -I{} -P ${JOBS} bash -c 'run_clang_format' {}
${CLANG_FORMAT} -i ${CDUP}/$0 || exit 1
}
diff --git a/scripts/environment.js b/scripts/environment.js
index 0468be3720..cb533a74a8 100755
--- a/scripts/environment.js
+++ b/scripts/environment.js
@@ -7,6 +7,7 @@ const github = require('@octokit/rest')();
const {execSync} = require('child_process');
const pr = process.env['CIRCLE_PULL_REQUEST'];
+const head = process.env['CIRCLE_SHA1'] || 'HEAD';
if (pr) {
const number = +pr.match(/\/(\d+)\/?$/)[1];
return github.pullRequests.get({
@@ -15,17 +16,15 @@ if (pr) {
number
}).then(({data}) => {
const base = data.base.ref;
- const head = process.env['CIRCLE_SHA1'];
const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim();
console.log(`export CIRCLE_TARGET_BRANCH=${base}`);
console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`);
});
} else {
- const head = process.env['CIRCLE_SHA1'];
for (const sha of execSync(`git rev-list --max-count=10 ${head}`).toString().trim().split('\n')) {
const base = execSync(`git branch -r --contains ${sha} origin/master origin/release-*`).toString().split('\n')[0].trim().replace(/^origin\//, '');
- if (base) {
+ if (base.match(/^(master|release-[a-z]+)$/)) {
const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim();
console.log(`export CIRCLE_TARGET_BRANCH=${base}`);
console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`);