Skip to content

Commit

Permalink
Add variables to override the commit author name and email
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans committed Oct 6, 2019
1 parent 90843d3 commit e138d84
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions create-pull-request.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def remote_branch_exists(repo, branch):
return False


def get_head_author(event_name, event_data):
def get_author_default(event_name, event_data):
if event_name == "push":
email = "{head_commit[author][email]}".format(**event_data)
name = "{head_commit[author][name]}".format(**event_data)
Expand Down Expand Up @@ -203,8 +203,11 @@ def process_event(event_name, event_data, repo, branch, base, remote_exists):
print("Pull request branch '%s' already exists for this commit. Skipping." % branch)
sys.exit()

# Get the HEAD committer's email and name
author_email, author_name = get_head_author(event_name, event_data)
# Get the default for author email and name
author_email, author_name = get_author_default(event_name, event_data)
# Set commit author overrides
author_email = os.getenv('COMMIT_AUTHOR_EMAIL', author_email)
author_name = os.getenv('COMMIT_AUTHOR_NAME', author_name)
# Set git configuration
set_git_config(repo.git, author_email, author_name)
# Checkout branch
Expand Down

0 comments on commit e138d84

Please sign in to comment.