Skip to content
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

Merged
merged 4 commits into from Dec 5, 2018
Merged

WIP: Staging Lines #338

merged 4 commits into from Dec 5, 2018

Conversation

jesseduffield
Copy link
Owner

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.

if !file.Tracked || !file.HasUnstagedChanges {
return gui.createErrorPanel(g, gui.Tr.SLocalize("FileStagingRequirements"))
}
gui.switchFocus(g, v, stagingView)

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)

return errors.New("No lines to stage")
}

gui.focusLineAndHunk()

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)

if overScroll < 0 {
overScroll = 0
}
v.SetOrigin(0, overScroll)

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)

overScroll = 0
}
v.SetOrigin(0, overScroll)
v.SetCursor(0, lineNumber-overScroll)

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)

}

// for logging purposes
ioutil.WriteFile("patch.diff", []byte(patch), 0600)

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)

panic(err)
}

gui.refreshStagingPanel()

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)

}

gui.refreshStagingPanel()
gui.refreshFiles(gui.g)

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-io
Copy link

codecov-io commented Dec 2, 2018

Codecov Report

Merging #338 into master will decrease coverage by 5.62%.
The diff coverage is 76.47%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
pkg/i18n/english.go 100% <100%> (ø) ⬆️
pkg/i18n/dutch.go 100% <100%> (ø) ⬆️
pkg/utils/utils.go 78.76% <100%> (+2.29%) ⬆️
pkg/i18n/polish.go 100% <100%> (ø) ⬆️
pkg/commands/os.go 76.84% <35.71%> (-7.11%) ⬇️
pkg/git/patch_modifier.go 58.97% <58.97%> (ø)
pkg/commands/git.go 92.6% <75%> (-0.78%) ⬇️
pkg/git/patch_parser.go 76.47% <76.47%> (ø)
pkg/git/branch_list_builder.go 0% <0%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6006055...933874f. Read the comment docs.

func (c *GitCommand) ApplyPatch(patch string) (string, error) {

content := []byte(patch)
tmpfile, err := ioutil.TempFile("", "patch")
Copy link
Owner Author

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

}

gui.refreshFiles(gui.g)
gui.refreshStagingPanel()

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)

@jesseduffield jesseduffield force-pushed the feature/staging_lines branch 4 times, most recently from 5df55c9 to fe3e3ea Compare December 3, 2018 11:19
@jesseduffield jesseduffield mentioned this pull request Dec 3, 2018
@jesseduffield
Copy link
Owner Author

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.

}
fmt.Fprint(filesView, list)

gui.correctCursor(filesView)

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)


gui.correctCursor(filesView)
if filesView == g.CurrentView() {
gui.handleFileSelect(g, filesView)

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())

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)

@rafi
Copy link

rafi commented Jan 8, 2019

This change deserves a new release ;)

@glvr182
Copy link
Contributor

glvr182 commented Jan 8, 2019

@rafi @jesseduffield is currently unavailable (afaik) so the release might be next week or later.

@jesseduffield
Copy link
Owner Author

I'm back from my holiday now :)

I'm gonna get a couple more bugfixes in, then do a release :)

@jesseduffield jesseduffield deleted the feature/staging_lines branch July 7, 2019 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants