-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs command: don't show error on console when not a git repository #3700
docs command: don't show error on console when not a git repository #3700
Conversation
puts "WARNING there is not inside git worktree. some features are not available." | ||
return | ||
end | ||
|
||
remotes = `git remote -v` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's enough to replace it with git remote -v 2>/dev/null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about git remote -v
perfectly. Maybe it causes an error event inside git work-tree. I think we should use git rev-parse --is-inside-work-tree
because it is official way to check whether inside git work-tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git remote
returns list of remotes with remote url after name (because of verbose -v
switch). Adding 2>/dev/null
will silence error while leaving status code intact, thus triggering return on the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git remote -v
error message except fatal: Not a git repository
may be useful for us, should not silence it. So, we should detect whether inside work-tree before git remote
.
89d48e8
to
68d011e
Compare
68d011e
to
4f511a1
Compare
4f511a1
to
6777410
Compare
@@ -20,6 +20,9 @@ class Crystal::Doc::Generator | |||
@types = {} of Crystal::Type => Doc::Type | |||
@repo_name = "" | |||
compute_repository | |||
if @repo_name == "" | |||
puts "WARNING cannot detect GitHub repository. some features are not available." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use a comma: "...repository, some features ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it.
Thank you! I wonder if we should show a warning or just silently do nothing if a git repo isn't found. You won't get links to the source code, but since that only works with github... if you are not using github then there isn't anything public to show links to, so saying nothing seems to be OK. (eventually we could add links to bitbuckets and other repositories) What do you think? |
6777410
to
8c8c095
Compare
@@ -278,6 +281,10 @@ class Crystal::Doc::Generator | |||
end | |||
|
|||
def compute_repository | |||
# check whether inside git work-tree | |||
`git rev-parse --is-inside-work-tree >/dev/null 2>&1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this additional command really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The below git remote -v
will output an error message without this. This is needed.
This PR is stalled. I don't know what needs to be done to continue. If there's no activity, it will be closed in two weeks. |
8c8c095
to
f51de4e
Compare
Sorry for delay. I'm sure preventing raw git error message is good, but I'm not sure it should show warning message. |
…rystal-lang#3700) * Show warning message if cannot detect GitHub repository * Remove warning message not to detect GitHub/GitLab repo
Currently, we get git error message when
crystal docs
run not inside git repository:It is unkind. This pull request fixes to output warning message instead of git error.