Skip to content

Commit

Permalink
chore: adds additional logging messages on bot.py
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
  • Loading branch information
jpower432 committed Jul 14, 2023
1 parent 58173bc commit 7851000
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if [[ -n ${INPUT_TARGET_BRANCH} ]]; then
exit 1
fi

command+=" --with-token <<<\"${GITHUB_TOKEN}\""
command+=" --with-token - <<<\"${GITHUB_TOKEN}\""
fi

exec 3>&1
Expand Down
11 changes: 6 additions & 5 deletions trestlebot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ def run(
# Only create a pull request if a GitProvider is configured and
# a target branch is set.
if git_provider is not None and target_branch:
logger.info("Git provider detected, submitting pull request")
logger.info(
f"Git provider detected, submitting pull request to {target_branch}"
)
# Parse remote url to get repository information for pull request
namespace, repo_name = git_provider.parse_repository(remote.url)
logger.debug("Detected namespace {namespace} and {repo_name}")

git_provider.create_pull_request(
ns=namespace,
Expand All @@ -177,11 +180,9 @@ def run(
return commit_sha

except GitCommandError as e:
raise RepoException(f"Git push to {branch} failed: {e}") from e
raise RepoException(f"Git push to {branch} failed: {e}")
except GitProviderException as e:
raise RepoException(
f"Git pull request to {target_branch} failed: {e}"
) from e
raise RepoException(f"Git pull request to {target_branch} failed: {e}")
else:
logger.info("Nothing to commit")
return commit_sha
Expand Down
6 changes: 5 additions & 1 deletion trestlebot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ def run() -> None:
)
sys.exit(1)

git_provider = GitHub(access_token=args.with_token)
if not args.with_token:
logger.error("with-token value cannot be empty")
sys.exit(1)

git_provider = GitHub(access_token=args.with_token.read().strip())

exit_code: int = 0

Expand Down

0 comments on commit 7851000

Please sign in to comment.