-
Notifications
You must be signed in to change notification settings - Fork 406
Open diff from editor #879
Conversation
|
Great addition. 😍 Should it open in a split pane? Also, I wonder if this replaces the "stage from editor" #46? For very small changes, it's ok to "blindly" stage without seeing a diff. But otherwise it's nice be able to take a quick look what you're going to stage. I think eventually, we should still offer some kind of "quick commit" option, but that's for another PR. |
5cf52fb to
6f1aba3
Compare
6f1aba3 to
a1541b2
Compare
This makes more sense architecturally since viewing the (un)staged changes for files is not a concern of the git tab
d25e493 to
ab16969
Compare
e3007d4 to
378cf85
Compare
Good idea @simurai. Added a config option (similar to what we have for
Yeah, I think this is a good alternative/replacement to staging directly from the editor. You think it's cool if I close out that issue with this PR? |
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.
One typo and a bunch of idle thoughts about further work from me. 👍
| @@ -364,7 +364,7 @@ export default class GitTabController { | |||
|
|
|||
| @autobind | |||
| quietlySelectItem(filePath, stagingStatus) { | |||
| return this.refs.gitTab.quitelySelectItem(filePath, stagingStatus); | |||
| return this.refs.gitTab.quietlySelectItem(filePath, stagingStatus); | |||
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.
Oops 🙈
lib/controllers/root-controller.js
Outdated
| @@ -43,7 +43,7 @@ export default class RootController extends React.Component { | |||
| static propTypes = { | |||
| workspace: PropTypes.object.isRequired, | |||
| commandRegistry: PropTypes.object.isRequired, | |||
| notificationManager: PropTypes.object.isRequired, | |||
| notificationManager: PropTypes.object.isReuired, | |||
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.
☝️ It looks like this one was spelled right the first time? Caught a stray backspace keypress maybe?
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.
Nice catch!
| amending: stagingStatus === 'staged' && this.state.isAmending, | ||
| }); | ||
| } else { | ||
| throw new Error(`${absFilePath} does not belong to repo ${repoPath}`); |
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.
Thinking this through: because the active text editor sets the active repository context, the only time that this could happen is if it's triggered in the window between opening an editor on a file not in the active repository and the render context change completing. Performance captures indicate that window is only in the tens of milliseconds range, so it's unlikely that anyone could hit this manually.
Eventually we might want to add logic to the effect of "wait on a Promise that resolves when the active context is what we expect it to be, then trigger diveIntoFilePatchForPath." Not worth holding up an initial merge for though I think.
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.
Just adding my two cents — my gut reaction is to feel slightly uncomfortable with assuming that the active repository is the one we want to use for all operations. For example, I've wanted the ability to "pin" a repo so that it's always active for a while now. On a related note, I think that the diff views should render irrespective of the active repository; that is, they set and maintain their own context outside of the "active" one.
|
|
||
| @autobind | ||
| viewUnstagedChangesForCurrentFile() { | ||
| this.viewChangesForCurrentFile('unstaged'); |
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.
I'd ❤️ to turn 'unstaged' and 'staged' into Symbols or another more enum-ish, non-String type.
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.
Great suggestion. I'll take a look into refactoring in a separate PR :)
| } | ||
| } | ||
|
|
||
| return this.selectLine(closestLine); |
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.
👍 This is pretty cool. 😄
| @autobind | ||
| goToDiffLine(lineNumber) { | ||
| return this.filePatchController.goToDiffLine(lineNumber); | ||
| } |
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.
Passing actions down the component hierarchy like this really feels like a "we should start looking at introducing Redux" smell to me 😆
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.
Yeah this felt icky to me. IIRC @BinaryMuse looked into Redux and dismissed using it for some reason. Can't remember what
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 way we manage model data doesn't suit itself well to Redux in my opinion. I also wanted to live with explicit props for a while to ensure we didn't switch to something a little more magical unless we really felt the pain and needed to — the abstraction, like any other, has a cost, and already the more meta-programmy parts of the package are the hardest to understand.
I do think we could use the other half of Redux — actions on the context — to good effect in the package. For example, anything that lives on the AtomEnvironment global could be placed on the context and components that need them could be wrapped in an HoC that accesses them (but allows them to be passed explicitly as props in tests). And other methods that perform actions that do not directly modify state and that do not affect rendering could be passed on context, as long as we're careful and selective about it.
| @@ -182,7 +182,7 @@ export default class GitTabView { | |||
| } | |||
|
|
|||
| @autobind | |||
| quitelySelectItem(filePath, stagingStatus) { | |||
| quietlySelectItem(filePath, stagingStatus) { | |||
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.
Haha oh wow. How many times have my eyes just glossed riiight over this one 😆
| { | ||
| 'label': 'View Staged Changes', | ||
| 'command': 'github:view-staged-changes-for-current-file' | ||
| } |
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.
Any opinions on keybindings to roll into #790 for these events?

Closes #888
Closes #46
This PR adds commands for easily viewing the diff associated with the active editor:
github:view-unstaged-changes-for-current-filegithub:view-staged-changes-for-current-fileThe RootController class
addedhunk line based on cursor position and scrolls it into view if necessaryAs part of this the FilePatchSelection API was extended to include a
goToDiffLine(lineNumber)method which selects the closestaddedline based on the passed in line number. This can be used for agithub:go-to-diff-linecommand similar to Atom's go-to-line functionality in editors. This is outside of the scope of the current PR, and may be implemented separately at a later point.