This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit with keyboard action #376
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ad21205
Unit tests for commit command
smashwilson 3c4c8f9
Install github:commit in the full workspace
smashwilson 6b6f681
Keymap entries for github:commit
smashwilson 495860c
Fixup: remove .only
smashwilson 9983fc9
Fixup: restore atom-text-editor keymap entries
smashwilson 4adc0aa
Temporary
smashwilson 906a4f1
Ensure the GitPanel is visible when github:commit is fired
smashwilson d901392
Update CommitView spec
smashwilson e174034
Call onChangeMessage from CommitViewController
smashwilson 3d6ef3c
Ensure that the git panel is shown
smashwilson d3c2ace
Ensure the Git panel is visible before committing
smashwilson b0dc042
Remove test for old behavior
smashwilson 6d62ae2
Stub ensureGitPanel in other specs
smashwilson a6b5506
Give an async prepareToCommit() function a chance to cancel commits
smashwilson 31c0fd3
Pass `this.props.prepareToCommit` through the component hierarchy
smashwilson c721566
If the git panel is hidden, show and focus it and abort the commit
smashwilson 40b492a
Shhh, eslint. Shhh
smashwilson 74b3c01
:fire: Code I thought I'd reverted <_< >_>
smashwilson f357ac1
Remove unnecessary .focus() call
smashwilson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,7 @@ export default class GitController extends React.Component { | |
| this.toggleGitPanelFocus = this.toggleGitPanelFocus.bind(this); | ||
| this.focusFilePatchView = this.focusFilePatchView.bind(this); | ||
| this.focusGitPanel = this.focusGitPanel.bind(this); | ||
| this.ensureGitPanel = this.ensureGitPanel.bind(this); | ||
|
|
||
| this.subscriptions = new CompositeDisposable(); | ||
| this.subscriptions.add( | ||
|
|
@@ -142,6 +143,7 @@ export default class GitController extends React.Component { | |
| didDiveIntoMergeConflictPath={this.diveIntoMergeConflictFileForPath} | ||
| didChangeAmending={this.didChangeAmending} | ||
| focusFilePatchView={this.focusFilePatchView} | ||
| ensureGitPanel={this.ensureGitPanel} | ||
| /> | ||
| </EtchWrapper> | ||
| </Panel> | ||
|
|
@@ -257,6 +259,18 @@ export default class GitController extends React.Component { | |
| return this.gitPanelController.getWrappedComponent().isFocused(); | ||
| } | ||
|
|
||
| // Ensure that the Git panel is visible. Returns a Promise that resolves to `true` if the panel was initially | ||
| // hidden or `false` if it was already shown. | ||
| ensureGitPanel() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I picked this name for consistency with the existing |
||
| if (!this.state.gitPanelActive) { | ||
| return new Promise((resolve, reject) => { | ||
| this.setState({gitPanelActive: true}, () => resolve(true)); | ||
| }); | ||
| } | ||
|
|
||
| return Promise.resolve(false); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Promise is needed here, because this is called from |
||
| } | ||
|
|
||
| focusFilePatchView() { | ||
| this.filePatchController.getWrappedComponent().focus(); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,10 @@ export default class CommitView { | |
| constructor(props) { | ||
| this.props = props; | ||
|
|
||
| this.commit = this.commit.bind(this); | ||
| this.abortMerge = this.abortMerge.bind(this); | ||
| this.handleAmendBoxClick = this.handleAmendBoxClick.bind(this); | ||
| this.commit = this.commit.bind(this); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 duplicate code! |
||
| this.abortMerge = this.abortMerge.bind(this); | ||
|
|
||
| etch.initialize(this); | ||
|
|
||
| this.editor = this.refs.editor; | ||
|
|
@@ -26,7 +25,7 @@ export default class CommitView { | |
| this.subscriptions = new CompositeDisposable( | ||
| this.editor.onDidChange(() => this.props.onChangeMessage && this.props.onChangeMessage(this.editor.getText())), | ||
| this.editor.onDidChangeCursorPosition(() => { etch.update(this); }), | ||
| props.commandRegistry.add(this.element, {'github:commit': this.commit}), | ||
| props.commandRegistry.add('atom-workspace', {'github:commit': this.commit}), | ||
| ); | ||
|
|
||
| const grammar = atom.grammars.grammarForScopeName(COMMIT_GRAMMAR_SCOPE); | ||
|
|
@@ -115,9 +114,11 @@ export default class CommitView { | |
| this.props.setAmending(this.refs.amend.checked); | ||
| } | ||
|
|
||
| commit() { | ||
| if (this.isCommitButtonEnabled()) { | ||
| async commit() { | ||
| if (await this.props.prepareToCommit() && this.isCommitButtonEnabled()) { | ||
| this.props.commit(this.editor.getText()); | ||
| } else { | ||
| this.focus(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ambient refactoring left over from a previous iteration on the implementation here. This bit looks cleaner to me so I left it.