Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Add a --keep-message option to avoid editing pull request messages. #109

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions git_pull_request/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def git_pull_request(
target_branch=None,
title=None,
message=None,
keep_message=None,
comment=None,
rebase=True,
download=None,
Expand Down Expand Up @@ -395,6 +396,7 @@ def git_pull_request(
user,
title,
message,
keep_message,
comment,
fork,
setup_only,
Expand Down Expand Up @@ -445,7 +447,7 @@ def edit_file_get_content_and_remove(filename):
editor = _run_shell_command(["git", "var", "GIT_EDITOR"], output=True)
if not editor:
LOG.warning(
"$EDITOR is unset, you will not be able to edit the " "pull-request message"
"$EDITOR is unset, you will not be able to edit the pull-request message"
)
editor = "cat"
status = os.system(editor + " " + filename)
Expand Down Expand Up @@ -502,6 +504,7 @@ def fork_and_push_pull_request(
user,
title,
message,
keep_message,
comment,
fork,
setup_only,
Expand Down Expand Up @@ -645,15 +648,19 @@ def fork_and_push_pull_request(
else:
ptitle = title

body = textparse.concat_with_ignore_marker(
message or git_message,
">\n> Current pull request content:\n"
+ pull.title
+ "\n\n"
+ pull.body,
)
if keep_message:
ptitle = pull.title
body = pull.body
else:
body = textparse.concat_with_ignore_marker(
message or git_message,
">\n> Current pull request content:\n"
+ pull.title
+ "\n\n"
+ pull.body,
)

ptitle, body = edit_title_and_message(ptitle, body)
ptitle, body = edit_title_and_message(ptitle, body)

if ptitle is None:
LOG.critical("Pull-request message is empty, aborting")
Expand Down Expand Up @@ -794,6 +801,13 @@ def build_parser():
)
parser.add_argument("--title", help="Title of the pull request.")
parser.add_argument("--message", "-m", help="Message of the pull request.")
parser.add_argument(
"--keep-message",
"-k",
action="store_true",
help="Don't open an editor to change the pull request message. "
"Useful when just refreshing an already-open pull request.",
)
parser.add_argument(
"--label",
"-l",
Expand Down Expand Up @@ -863,6 +877,7 @@ def main():
target_branch=args.target_branch,
title=args.title,
message=args.message,
keep_message=args.keep_message,
comment=args.comment,
rebase=not args.no_rebase,
download=args.download,
Expand Down