Skip to content

Commit

Permalink
Merge pull request #391 from DataRecce/feature/drc-556-refine-the-err…
Browse files Browse the repository at this point in the history
…or-message-if-pr-is-not-ready

[Enhancement] Fix the error message for cloud mode
  • Loading branch information
popcornylu authored Jul 19, 2024
2 parents 5d7948a + ccc9fa3 commit a1667e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion recce/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def get_pull_request(branch, owner, repo_name, github_token=None):
return pr

except UnknownObjectException:
print(f"Repository {owner}/{repo_name} not found. Please provide '$GITHUB_TOKEN' environment variable.")
if github_token is None:
print(f"Repository {owner}/{repo_name} not found. Please provide '$GITHUB_TOKEN' environment variable.")
else:
print(
f"Repository {owner}/{repo_name} not found. If it is private repo, please add the 'repo' scope to the token.")
return None

return None
Expand All @@ -136,6 +140,9 @@ def recce_pr_information(github_token=None) -> PullRequest:
branch = current_branch()
repo = hosting_repo()

if not repo:
print('This is not a git repository.')
return
if '/' not in repo:
print('This is not a GitHub repository.')
return
Expand Down
7 changes: 4 additions & 3 deletions recce/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ def __init__(self,
self.pr_info = None

if self.cloud_mode:
if self.cloud_options.get('token'):
self.pr_info = fetch_pr_metadata(github_token=self.cloud_options.get('token'))
else:
if not self.cloud_options.get('token'):
raise Exception('No GitHub token is provided to access the pull request information.')
self.pr_info = fetch_pr_metadata(github_token=self.cloud_options.get('token'))
if self.pr_info.id is None:
raise Exception('Cannot get the pull request information from GitHub.')

# Load the state
self.load()
Expand Down

0 comments on commit a1667e9

Please sign in to comment.