-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luís Freitas
authored and
Luís Freitas
committed
Jun 30, 2024
1 parent
f2486ab
commit 403c0a0
Showing
1 changed file
with
5 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,15 +31,16 @@ def merge_source_into_target(target_repo, remote_name, branch_name): | |
try: | ||
target_repo.git.merge(f"{remote_name}/main", allow_unrelated_histories=True) | ||
target_repo.git.push("origin", branch_name) | ||
print(f"Successfully merged '{remote_name}/main' into '{branch_name}'") | ||
return True | ||
except git.exc.GitCommandError as e: | ||
print(f"Merge conflict detected: {e}") | ||
print(f"Error during merge: {e}") | ||
return False | ||
|
||
def main(): | ||
# Configure Git user identity | ||
configure_git_identity() | ||
|
||
# Target and Source repo can be set as env variable | ||
target_repo_url = "[email protected]:lsfreitas/target.git" | ||
source_repo_url = "[email protected]:lsfreitas/source.git" | ||
|
@@ -64,10 +65,8 @@ def main(): | |
print(f"Remote '{remote_name}' created and fetched") | ||
|
||
merge_success = merge_source_into_target(target_repo, remote_name, branch_name) | ||
if merge_success: | ||
print(f"Successfully merged '{remote_name}/main' into '{branch_name}'") | ||
else: | ||
print(f"Failed to merge '{remote_name}/main' into '{branch_name}' due to conflicts") | ||
if not merge_success: | ||
print(f"Failed to merge '{remote_name}/main' into '{branch_name}' due to conflicts or other errors") | ||
|
||
if __name__ == "__main__": | ||
main() |