Skip to content
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

Merged
merged 1 commit into from
Jul 9, 2019

Conversation

westbury
Copy link
Contributor

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.

Copy link
Member

@paul-marechal paul-marechal left a 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.

packages/git/src/node/dugite-git.ts Outdated Show resolved Hide resolved
packages/git/src/node/dugite-git.ts Outdated Show resolved Hide resolved
@westbury
Copy link
Contributor Author

The Git History view displays a loading icon indefinitely, when it used to show an error message:

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.

@westbury
Copy link
Contributor Author

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>
Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @kittaakos?

@akosyakov akosyakov added the git issues related to git label Jul 5, 2019
@akosyakov
Copy link
Member

@kittaakos would it be fine to merge it, since @marechal-p tested changes already?

@kittaakos
Copy link
Contributor

would it be fine to merge it

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 revParse on the Git API as it is called from the backend only. But that's fine.

@westbury
Copy link
Contributor Author

westbury commented Jul 8, 2019

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.

@akosyakov
Copy link
Member

@marechal-p Could you nominate @westbury as a Theia committer please? that he can merge as well

@akosyakov akosyakov merged commit 61f092f into eclipse-theia:master Jul 9, 2019
@westbury westbury deleted the GH5435 branch July 9, 2019 09:16
@marcdumais-work
Copy link
Contributor

Note: @marechal-p is on vacation ATM, back middle of next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
git issues related to git
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request 'log' failed from scm amend
5 participants