Skip to content

Commit

Permalink
merge_source_into_target func
Browse files Browse the repository at this point in the history
  • 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.
11 changes: 5 additions & 6 deletions merge_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()

0 comments on commit 403c0a0

Please sign in to comment.