-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve support for empty Git repository in Git view #5484
Conversation
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 Git History view displays a loading icon indefinitely, when it used to show an error message:
There is no Git history available for in xxx
Request log failed with message: Bad revision.
Don't know if this is intended.
Thank you for testing this and finding this problem. On investigating, the problem is caused firstly by the code in GitHistoryWidget addCommits() which sees no commits, ends up calling git.lsFiles and finds that there is a repository. It does not set an error message because pathIsUnderVersionControl is true. Then render() is called, it sees there are no commits, it also sees there is no error message, so it falls thru to the final 'else' and shows the progress indicator (assuming incorrectly that either some commits or an error will arrive at some point). I'll sort this out tomorrow. |
I have now fixed up the Git History view too. Also changed the commit message to include 'Git History'. The messages were a little confused, causing the 'There is no Git history available for in xxx' message. Though not connected to this PR, I re-wrote the error message rendering to fix that. |
Signed-off-by: Nigel Westbury <nigelipse@miegel.org>
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.
LGTM, @kittaakos?
@kittaakos would it be fine to merge it, since @marechal-p tested changes already? |
Apologies, I thought I have already approved this. I must have been confused with this. Sure 👍 One remark though, it was not necessary to expose |
I'm fine for this to be merged. As soon that this is merged I will rebase #5451 and update it to allow modifying the initial commit. |
@marechal-p Could you nominate @westbury as a Theia committer please? that he can merge as well |
Note: @marechal-p is on vacation ATM, back middle of next week. |
This fixes #5435
There are two parts to this. The first part changes 'log' function so that an empty array is returned when the Git repository is empty (no HEAD).
Rather than check for an empty repository before every call to 'log', we check for the empty repository only after an error. This was done to avoid an extra Git command on every 'log'.
Having made that change, a change to ScmAmendComponent was necessary to cause the 'last commit' section to appear when the initial commit is committed.
This can be tested by showing a newly-created empty repository in the Scm view. Commit the initial commit and the 'last commit' section appears. Remove the initial commit and it disappears. You can remove the initial commit by deleting .git/refs/heads/master.
I recommend merging this PR before #5451 . I believe I can re-work that PR on top of this one to implement @svenefftinge's amending of the initial commit.