@@ -13,12 +13,12 @@ class GitUtilsException(Exception):
13
13
pass
14
14
15
15
16
- def _remote_origin_master (git_repo ):
17
- # type: (repo.Repo) -> head.Head
18
- remote_master = git_repo .heads . master .tracking_branch ()
19
- if not remote_master or not remote_master .is_valid ():
20
- raise GitUtilsException ("Unable to locate remote branch origin/master" )
21
- return remote_master
16
+ def _remote_origin_branch (git_repo , branch ):
17
+ # type: (repo.Repo, str ) -> head.Head
18
+ remote_branch = git_repo .heads [ branch ] .tracking_branch ()
19
+ if not remote_branch or not remote_branch .is_valid ():
20
+ raise GitUtilsException ("Unable to locate remote branch origin/{}" . format ( branch ) )
21
+ return remote_branch
22
22
23
23
24
24
def _modified_in_branch (git_repo , other_ref ):
@@ -48,12 +48,12 @@ def _file_is_python(path):
48
48
return False
49
49
50
50
51
- def changed_python_files_in_tree (root_path ):
52
- # type: (str) -> typing.List[str]
51
+ def changed_python_files_in_tree (root_path , base = 'master' ):
52
+ # type: (str, typing.Optional[str] ) -> typing.List[str]
53
53
54
54
git_repo = repo .Repo (root_path )
55
- remote_master = _remote_origin_master (git_repo )
56
- modified = _modified_in_branch (git_repo , remote_master )
55
+ remote_branch = _remote_origin_branch (git_repo , base )
56
+ modified = _modified_in_branch (git_repo , remote_branch )
57
57
abs_modified = [os .path .join (git_repo .working_dir , x ) for x in modified ]
58
58
return [mod for (mod , abs_mod ) in zip (modified , abs_modified )
59
59
if os .path .exists (abs_mod ) and os .path .isfile (abs_mod ) and _file_is_python (abs_mod )]
0 commit comments