File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,23 @@ def log_paths(logger, paths):
60
60
logger .info (f"PATHS:{ paths_list } " )
61
61
62
62
63
- def fetch_and_merge (repo_path , branch = "gsoc2024-dev-1" ):
63
+ def fetch_and_merge (repo_path , branch = None ):
64
64
try :
65
65
repo = Repo (repo_path )
66
66
origin = repo .remote (name = "origin" )
67
67
origin .fetch ()
68
+
69
+ # Determine the branch to use
70
+ if branch is None :
71
+ # Use the current branch if no branch is provided
72
+ branch = repo .active_branch .name if repo .active_branch else "main"
73
+
74
+ # Ensure that the branch exists in the remote
75
+ if f"origin/{ branch } " not in [ref .name for ref in repo .refs ]:
76
+ raise ValueError (
77
+ f"Branch '{ branch } ' does not exist in remote 'origin'"
78
+ )
79
+
68
80
repo .git .merge (f"origin/{ branch } " , allow_unrelated_histories = True )
69
81
logging .info (f"Fetched and merged latest changes from { branch } " )
70
82
except InvalidGitRepositoryError :
You can’t perform that action at this time.
0 commit comments