Skip to content

Commit 839d799

Browse files
Increase Git depth for linter. Linte will check if depth is sufficient before running
1 parent 549e37e commit 839d799

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ language: minimal
3939
#compiler: gcc
4040

4141
git:
42-
depth: 5
42+
#Use maximal depth to ensure linter can determine common merge-point
43+
depth: 50
4344

4445
before_install:
4546
- pip install --user cpp-coveralls cpplint

utils/run_linter.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ def main():
7070
logging.debug("TRAVIS_PULL_REQUEST_SHA: %s", TRAVIS_PULL_REQUEST_SHA)
7171
logging.debug("TRAVIS_BRANCH: %s", TRAVIS_BRANCH)
7272
logging.debug("TRAVIS_REPO_SLUG: %s", TRAVIS_REPO_SLUG)
73-
7473
changed = {}
7574
if args.diff:
7675
if TRAVIS and not TRAVIS_PULL_REQUEST:
7776
# FIXME: This shouldn't be needed, but not sure why TRAVIS is so special
7877
return
78+
check_depth()
7979
changed = get_changed_lines()
8080

8181
paths = filter_paths(args.path, changed, pwd)
@@ -376,5 +376,15 @@ def system(cmd):
376376
else:
377377
return subprocess.check_output(cmd, shell=True)
378378

379+
def check_depth():
380+
if TRAVIS and TRAVIS_PULL_REQUEST_SHA:
381+
with open(os.devnull, 'w') as devnull:
382+
if subprocess.call(["git", "merge-base", TRAVIS_PULL_REQUEST_SHA, TRAVIS_BRANCH], stdout=devnull):
383+
# Current depth is not deep enough
384+
logging.debug(system(["git", "fetch", "--deepen", "100"]))
385+
if subprocess.call(["git", "merge-base", TRAVIS_PULL_REQUEST_SHA, TRAVIS_BRANCH], stdout=devnull):
386+
logging.error("Can't find common base for comparison. Aborting")
387+
sys.exit(1)
388+
379389

380390
main()

0 commit comments

Comments
 (0)