Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Handle repositories with no commits - #533

Merged
smashwilson merged 24 commits into
masterfrom
aw-fear-of-commitment
Feb 28, 2017
Merged

smashwilson merged 24 commits into
masterfrom
aw-fear-of-commitment

Conversation

@smashwilson

@smashwilson smashwilson commented Feb 17, 2017 •

Copy link
Copy Markdown
Contributor

Gracefully handle repositories that have been freshly initialized and have no commits. You should be able to create that initial commit without 💥.

  • Handle a repository containing an unborn HEAD.
    • Use git symbolic-ref to retrieve the current branch if HEAD is a symbolic reference.
    • Conceal the "amend" button on an unborn HEAD (because there's no commit to amend).
  • Handle a repository with a detached HEAD.
    • Use git describe --contains --all to retrieve a human-readable branch description.
    • Style the BranchView differently when it's showing a detached HEAD.
    • Display the HEAD description in the BranchMenuView dropdown, but disable it.
    • Disable the push and pull controls and display a more relevant error message in the PushPullMenuView.

Fixes #217.

@smashwilson

Copy link
Copy Markdown
Contributor Author

This is almost certainly going to collide a bunch with #524, but having the test cases in place will be helpful for not breaking this case moving forward.

@smashwilson smashwilson added this to the Public Release milestone Feb 23, 2017
@smashwilson smashwilson self-assigned this Feb 23, 2017
@smashwilson

Copy link
Copy Markdown
Contributor Author

Coming along! Mostly now I'm deciding how to represent a detached HEAD in various bits of the UI, like the BranchView dropdown.

@smashwilson

Copy link
Copy Markdown
Contributor Author

Okay, this now adapts to unborn and detached HEADs in what I think is a reasonable way.

While you're on an unborn HEAD (a new repository), the only real change in behavior is that the "amend" control isn't rendered (well, and it doesn't spew errors into your console).

When you're on a detached HEAD:

  • The BranchView displays output from git describe and displays with text-subtle:
    screen shot 2017-02-24 at 3 59 57 pm
  • When opening the BranchMenuView shows the git describe output as a disabled option in the select box:
    screen shot 2017-02-27 at 12 05 10 pm
  • The PushPullMenuView disables the Pull and Push buttons and shows a custom message:
    screen shot 2017-02-27 at 2 30 11 pm

name: (await this.exec(['describe', '--contains', '--all', 'HEAD'])).trim(),
isDetached: true,
};
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

☝️ This bit is done consistently with the way that git-prompt.sh decorates your PS1. A bit messy but it should be fairly robust?

@BinaryMuse

Copy link
Copy Markdown
Contributor

@smashwilson I apologize, but do you mind updating to include the Yubikiri changes before I review? (Alternatively I can do it for you since it's my fault you have conflicts 😅)

@BinaryMuse BinaryMuse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another thought: could it be interesting to prompt a user (like Git does) if they make a detached commit and then change to a branch?

Comment thread lib/views/branch-menu-view.js Outdated
branchName: React.PropTypes.string,
currentBranch: React.PropTypes.shape({
name: React.PropTypes.string,
isDetached: React.PropTypes.bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's mark name and isDetached as .isRequired

Comment thread lib/views/branch-view.js Outdated
branchName: React.PropTypes.string,
currentBranch: React.PropTypes.shape({
name: React.PropTypes.string,
isDetached: React.PropTypes.bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here (even better, extract this into prop-types.js)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Much cleaner 🎨

Comment thread lib/views/push-pull-menu-view.js Outdated
branchName: React.PropTypes.string,
currentBranch: React.PropTypes.shape({
name: React.PropTypes.string,
isDetached: React.PropTypes.bool,

@BinaryMuse BinaryMuse Feb 28, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

☝️

687474703a2f2f6d7277676966732e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031332f30352f492d4c696b652d49742d416e6f746865722d54686f722d5265616374696f6e2d4769662e676966

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Strong .gif game as always 😀

@smashwilson

Copy link
Copy Markdown
Contributor Author

Another thought: could it be interesting to prompt a user (like Git does) if they make a detached commit and then change to a branch?

❤️ Well worth doing. I'll make a follow-on issue 👍

@smashwilson
smashwilson merged commit 762c774 into master Feb 28, 2017
@smashwilson
smashwilson deleted the aw-fear-of-commitment branch February 28, 2017 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants