Skip to content

Commit

Permalink
Raise an error if we push no commits, instead of just printing an err…
Browse files Browse the repository at this point in the history
…or and exiting with success. Also, drop log level to WARN.
  • Loading branch information
harshita-gupta committed May 29, 2024
1 parent 804f845 commit d615ca8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inputs:
default: 'origin'
log_level:
description: 'Log level, specified using the standard Python logging module levels. Default is WARN. Options are DEBUG, INFO, WARN, ERROR.'
default: 'INFO'
default: 'WARN'
runs:
using: 'composite'
steps:
Expand Down
10 changes: 3 additions & 7 deletions create_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def main(
commit_message_lines = commit_message.split("\n")
headline = commit_message_lines[0]
body = "\n".join(commit_message_lines[1:])
body += f"\n\nThis commit was created from the local commit with hash {local_commit_hash}."
commit_message = CommitMessage(headline=headline, body=body)

file_changes = get_file_changes_from_local_commit_hash(local_commit_hash)
Expand Down Expand Up @@ -499,18 +500,13 @@ def main(
except (RemoteBranchDivergedError, GithubAPIError) as e:
if not last_commit_pushed:
# If we haven't pushed any commits yet, then the error is less severe. We'll print
# an error, but we won't raise an exception - this means the Github Action's status
# will still be 'success'.
# an error that explains this, and will raise an exception.
logging.error(
"An error occurred while pushing the first commit to the remote branch. "
"This action made no changes to the remote branch. Error message: %s",
e,
)
return
else:
# If we've already pushed some commits, then the error is more severe. We'll raise an
# exception.
raise e
raise e

remote_commit_hashes_created.append(last_commit_pushed)
logging.info(
Expand Down

0 comments on commit d615ca8

Please sign in to comment.