def difftree_generate_patch(repo, optDict): git = repo.git dest = os.path.join(optDict.get("dest"), "patchset") print("\n") print("## Generate patches with git format-patch at"+dest) if not os.path.exists(dest): os.mkdir(dest) result = git.format_patch(optDict.get("oldrev"), o=dest) print(result)
# Remove remote repo name from branch name if present. This assumes that we don't use '/' in # actual branch names. base_branch_without_remote = base_branch.split('/')[-1] logger.info(" Base branch: %s", base_branch) check_diff_between_branches(base_branch) patch_dir = os.path.abspath(os.path.expanduser(args.patch_dir)) logger.info(" Patch directory: %s", patch_dir) validate_patch_dir(patch_dir) patch_filename = get_patch_name(base_branch_without_remote) logger.info(" Patch name: %s", patch_filename) patch_filepath = os.path.join(patch_dir, patch_filename) diff = git.format_patch(base_branch, stdout=True) with open(patch_filepath, "w") as f: f.write(diff.encode('utf8')) if args.jira_id is not None: creds = get_credentials() issue_url = "https://issues.apache.org/jira/rest/api/2/issue/" + args.jira_id attach_patch_to_jira(issue_url, patch_filepath, patch_filename, creds) if not args.skip_review_board: rb_auth = requests.auth.HTTPBasicAuth(creds['rb_username'], creds['rb_password']) rb_link_title = "Review Board (" + base_branch_without_remote + ")" rb_id = get_review_board_id_if_present(issue_url, rb_link_title)
# Remove remote repo name from branch name if present. This assumes that we don't use '/' in # actual branch names. base_branch_without_remote = base_branch.split('/')[-1] logger.info(" Base branch: %s", base_branch) check_diff_between_branches(base_branch) patch_dir = os.path.abspath(os.path.expanduser(args.patch_dir)) logger.info(" Patch directory: %s", patch_dir) validate_patch_dir(patch_dir) patch_filename = get_patch_name(base_branch_without_remote) logger.info(" Patch name: %s", patch_filename) patch_filepath = os.path.join(patch_dir, patch_filename) diff = git.format_patch(base_branch, stdout = True) with open(patch_filepath, "wb") as f: f.write(diff.encode('utf8')) if args.jira_id is not None: creds = get_credentials() issue_url = "https://issues.apache.org/jira/rest/api/2/issue/" + args.jira_id attach_patch_to_jira(issue_url, patch_filepath, patch_filename, creds) if not args.skip_review_board: rb_auth = requests.auth.HTTPBasicAuth(creds['rb_username'], creds['rb_password']) rb_link_title = "Review Board (" + base_branch_without_remote + ")" rb_id = get_review_board_id_if_present(issue_url, rb_link_title)