brackets-userland / brackets-git

brackets-git — git extension for adobe/brackets
Other
656 stars 193 forks source link

Incorrect branch name (displaying 'true') #1291

Open Jiedara opened 8 years ago

Jiedara commented 8 years ago

Hi.

I saw that bug append right before my very first commit: Branch won't show up correctly under the project name. Instead, the branch name is replaced by 'true' and I can't neither add index or change branch...

Here is a what I saw : buggitbracket

This happened in a very classic repository, except that there was no commit made yet. After the first commit, everything came back to normal :+1: I don't have any console information, because I made my commit before looking at it ... sorry Not a hard bug, but this can be tricky for a new git user that can't understand how to handle it ...

zaggino commented 8 years ago

@peey this is I assume caused by your https://github.com/zaggino/brackets-git/pull/1289 can you have a look?

peey commented 8 years ago

Your assumptions seem true. This behavior first appears in v0.16.4

Steps for reproducing the bug

  1. Create new folder
  2. git init
  3. Open the folder in brackets

v0.16.3 behavior

  1. A gitignore file is created by extn and commited

v0.16.4 behavior

  1. A gitignore file is created, no commits exist yet.
  2. The part that should display the branch name oscillates between "..." and "true". Further, if you try to open a context menu by right clicking or clicking on the branch name, the context menu soon disappears as happens when you click elsewhere. It goes away after the first commit.

Still investigating

peey commented 8 years ago

Git.getCurrentBranchName() is returning true in Branch.js, line 436. I think it is supposed to return a string and that's what causing this bug.

This was probably not introduced by #1289 but uncovered by it. Does any part of branch determining code depend on the repository having at least one commit, @zaggino?

zaggino commented 8 years ago

Released 0.16.5 which should address this.

peey commented 8 years ago

The original issue is fixed now. However there's a new one which I think is related to this code.

If I create a new branch before the first commit, its name does not reflect in the UI. Steps for reproducing issue:

  1. git init in an empty directory
  2. click on the branch name "master" in brackets
  3. click "create-new-branch" in the context menu
  4. enter "new-branch" in branch name, click OK
  5. check git status via command line in current folder

Git status shows the current branch to be "new-branch" as expected. If you commit via the brackets git extension it makes the commit in "new-branch" as well. But on the UI it displays "master" for the branch name till brackets is refreshed/new branch is created.

This issue does not happen if you create a branch after the first commit. Only happens in an uinitialized repository.

Unsure if I should open a separate issue for this or not.

zaggino commented 8 years ago

We can have it here as a bug but I don't consider it critical by any means.

The place where code needs to be updated for the fix is here: https://github.com/zaggino/brackets-git/blob/master/src/git/GitCli.js#L435

You need to execute some git command to get the branch name.