Skip to content

Commit c00db84

Browse files
authored
Merge pull request #469 from GoogleCloudPlatform/nox-travis-is-dumb
2 parents 85176d4 + 2ec46c9 commit c00db84

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

nox.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,25 @@ def get_changed_files():
9696
changed = subprocess.check_output(
9797
['git', 'show', '--pretty=format:', '--name-only',
9898
os.environ.get('TRAVIS_COMMIT')])
99+
99100
elif pr is not None:
100-
changed = subprocess.check_output(
101-
['git', 'diff', '--name-only',
102-
os.environ.get('TRAVIS_COMMIT'),
103-
os.environ.get('TRAVIS_BRANCH')])
101+
try:
102+
changed = subprocess.check_output(
103+
['git', 'diff', '--name-only',
104+
os.environ.get('TRAVIS_COMMIT'),
105+
os.environ.get('TRAVIS_BRANCH')])
106+
107+
except subprocess.CalledProcessError:
108+
# Fallback to git head.
109+
git_head = subprocess.check_output(
110+
['git', 'rev-parse', 'HEAD']).strip()
111+
112+
print('Falling back to HEAD: {}'.format(git_head))
113+
114+
changed = subprocess.check_output(
115+
['git', 'diff', '--name-only',
116+
os.environ.get('TRAVIS_COMMIT'),
117+
os.environ.get('TRAVIS_BRANCH')])
104118
else:
105119
changed = ''
106120
print('Uh... where are we?')

0 commit comments

Comments
 (0)