@@ -163,6 +163,23 @@ def get_changed_packages(blob_name1, blob_name2, package_list):
163163 return sorted (result )
164164
165165
166+ def local_diff_branch ():
167+ """Get a remote branch to diff against in a local checkout.
168+
169+ Checks if the the local remote and local branch environment
170+ variables specify a remote branch.
171+
172+ :rtype: str
173+ :returns: The diffbase `{remote}/{branch}` if the environment
174+ variables are defined. If not, returns ``None``.
175+ """
176+ # Only allow specified remote and branch in local dev.
177+ remote = os .getenv (LOCAL_REMOTE_ENV )
178+ branch = os .getenv (LOCAL_BRANCH_ENV )
179+ if remote is not None and branch is not None :
180+ return '%s/%s' % (remote , branch )
181+
182+
166183def get_affected_files (allow_limited = True ):
167184 """Gets a list of files in the repository.
168185
@@ -195,11 +212,7 @@ def get_affected_files(allow_limited=True):
195212 if in_travis_pr ():
196213 diff_base = travis_branch ()
197214 else :
198- # Only allow specified remote and branch in local dev.
199- remote = os .getenv (LOCAL_REMOTE_ENV )
200- branch = os .getenv (LOCAL_BRANCH_ENV )
201- if remote is not None and branch is not None :
202- diff_base = '%s/%s' % (remote , branch )
215+ diff_base = local_diff_branch ()
203216
204217 if diff_base is not None and allow_limited :
205218 result = subprocess .check_output (['git' , 'diff' , '--name-only' ,
0 commit comments