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
WIP: Staging Lines #338
WIP: Staging Lines #338
Conversation
pkg/gui/files_panel.go
Outdated
if !file.Tracked || !file.HasUnstagedChanges { | ||
return gui.createErrorPanel(g, gui.Tr.SLocalize("FileStagingRequirements")) | ||
} | ||
gui.switchFocus(g, v, stagingView) |
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.
Error return value of gui.switchFocus
is not checked (from errcheck
)
pkg/gui/staging_panel.go
Outdated
return errors.New("No lines to stage") | ||
} | ||
|
||
gui.focusLineAndHunk() |
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.
Error return value of gui.focusLineAndHunk
is not checked (from errcheck
)
pkg/gui/staging_panel.go
Outdated
if overScroll < 0 { | ||
overScroll = 0 | ||
} | ||
v.SetOrigin(0, overScroll) |
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.
Error return value of v.SetOrigin
is not checked (from errcheck
)
pkg/gui/staging_panel.go
Outdated
overScroll = 0 | ||
} | ||
v.SetOrigin(0, overScroll) | ||
v.SetCursor(0, lineNumber-overScroll) |
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.
Error return value of v.SetCursor
is not checked (from errcheck
)
pkg/gui/staging_panel.go
Outdated
} | ||
|
||
// for logging purposes | ||
ioutil.WriteFile("patch.diff", []byte(patch), 0600) |
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.
Error return value of ioutil.WriteFile
is not checked (from errcheck
)
pkg/gui/staging_panel.go
Outdated
panic(err) | ||
} | ||
|
||
gui.refreshStagingPanel() |
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.
Error return value of gui.refreshStagingPanel
is not checked (from errcheck
)
pkg/gui/staging_panel.go
Outdated
} | ||
|
||
gui.refreshStagingPanel() | ||
gui.refreshFiles(gui.g) |
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.
Error return value of gui.refreshFiles
is not checked (from errcheck
)
Codecov Report
@@ Coverage Diff @@
## master #338 +/- ##
==========================================
- Coverage 94.43% 88.81% -5.63%
==========================================
Files 13 16 +3
Lines 1797 2083 +286
==========================================
+ Hits 1697 1850 +153
- Misses 97 221 +124
- Partials 3 12 +9
Continue to review full report at Codecov.
|
pkg/commands/git.go
Outdated
func (c *GitCommand) ApplyPatch(patch string) (string, error) { | ||
|
||
content := []byte(patch) | ||
tmpfile, err := ioutil.TempFile("", "patch") |
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 should move the write-to-temp-file code to the OS package because it's not git-specific
4ca1154
to
a2f336f
Compare
pkg/gui/staging_panel.go
Outdated
} | ||
|
||
gui.refreshFiles(gui.g) | ||
gui.refreshStagingPanel() |
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.
Error return value of gui.refreshStagingPanel
is not checked (from errcheck
)
5df55c9
to
fe3e3ea
Compare
The remaining negative percentage points from codecov can only really be covered with some mocking infrastructure which I don't quite have the energy to implement at the moment. I'll leave that for another PR. |
pkg/gui/files_panel.go
Outdated
} | ||
fmt.Fprint(filesView, list) | ||
|
||
gui.correctCursor(filesView) |
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.
Error return value of gui.correctCursor
is not checked (from errcheck
)
pkg/gui/files_panel.go
Outdated
|
||
gui.correctCursor(filesView) | ||
if filesView == g.CurrentView() { | ||
gui.handleFileSelect(g, filesView) |
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.
Error return value of gui.handleFileSelect
is not checked (from errcheck
)
pkg/gui/gui.go
Outdated
@@ -304,7 +331,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { | |||
return err | |||
} | |||
|
|||
gui.handleFileSelect(g, filesView) | |||
gui.g.SetCurrentView(filesView.Name()) |
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.
Error return value of gui.g.SetCurrentView
is not checked (from errcheck
)
b679bbe
to
fe3e3ea
Compare
fe3e3ea
to
2df6789
Compare
2df6789
to
933874f
Compare
This change deserves a new release ;) |
@rafi @jesseduffield is currently unavailable (afaik) so the release might be next week or later. |
I'm back from my holiday now :) I'm gonna get a couple more bugfixes in, then do a release :) |
Feels GOOD to put this PR up.
It's a WIP right now but basically works. Press enter in the files panel on a tracked file with unstaged changes, and you'll be able to use the up/down keys to cycle through unstaged lines, and left/right to cycle through hunks. Pressing space on a line will stage that line, and pressing 'a' will stage the hunk of the currently focused line.
Before I merge this I want to add some more unit tests and ensure that I've got my strings all i18n'd, and that I'm logging the right stuff where I should be. I might make another PR down the line to support reverting lines.