in devai-cli/src/devai/commands/github_cmd.py [0:0]
def create_github_pr(branch: str, files: dict[str, str]):
"""Opens new GitHub Pull Request with updated files
Args:
branch (str): branch name.
files (dict[str, str]): file path and content pairs
"""
try:
resp = github.create_branch(branch)
print(resp)
except Exception as e:
print(f"Error creating branch: {e}")
return
existing_files = {}
existing_source_code = ""
new_source_code = ""
for filepath, content in files.items():
try:
old_file_contents = github.read_file(filepath)
existing_files[filepath] = old_file_contents
resp = github.update_file(file_update_request.format(filepath, old_file_contents, content))
print(resp)
existing_source_code += f"\nFile: {filepath}\nContent:\n{old_file_contents}"
new_source_code += f"\nFile: {filepath}\nContent:\n{content}"
except Exception as e:
print(f"Error updating file {filepath}: {e}")
return
try:
pr_summary = generate_pr_summary(existing_source_code, new_source_code)
resp = github.create_pull_request(pr_summary)
print(resp)
except Exception as e:
print(f"Error creating pull request: {e}")
return