-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add streaming git command status panel #296
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
Conversation
scbizu
commented
Sep 20, 2018
pkg/gui/command_status_panel.go
Outdated
const ( | ||
// cmdStatusLen is a magic number | ||
// that defines the max columns of CommandStatus panel | ||
cmdStatusLen = 12 |
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.
cmdStatusLen
is unused
Very good idea! This looks like a very promising PR |
[off topic] @scbizu ingress enlightened spotted :) |
3cdb39e
to
c6601b5
Compare
Codecov Report
@@ Coverage Diff @@
## master #296 +/- ##
==========================================
+ Coverage 84.89% 84.98% +0.09%
==========================================
Files 21 21
Lines 3515 3537 +22
==========================================
+ Hits 2984 3006 +22
Misses 491 491
Partials 40 40
Continue to review full report at Codecov.
|
pkg/commands/git_test.go
Outdated
func TestGitCommandCommitWithStatus(t *testing.T) { | ||
type scenario struct { | ||
testName string | ||
command func(string, ...string) *cmd.Cmd |
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.
command
is unused
3cc7347
to
96f2b36
Compare
pkg/gui/command_status_panel.go
Outdated
go func() { | ||
for { | ||
select { | ||
case status := <-cs.command.Stdout: |
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.
what would be an example value for status? Would it be a random string read from the buffer, or a single character etc?
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.
also I'm not sure if this is possible but can we call cs.refreshCommandStatus(cs.gui, "")
after the command has completed so that we have line breaks between the outputs of different commands (utilising the newline added in refreshCommandStatus
)?
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 value will be the plain git command output, you can check the output within the dev mode by grep
collect\ message
,however, I will rename it with thecmdOutput
for better understanding . -
Do you mean add new line break for different git command? To implement this, I think we'd better to pass a
echo \n
(shell) to command status panel.
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.
yes, that's what I mean. Although we'd still need to know when to pass that command, which would require us to know when the first command has finished, which if we knew, we could just add a newline. I'm happy to leave this issue as too-tricky-to-solve for now, unless you have an idea of how to do it :)
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. we can receive the done singnal when the cmd is done. And then we add this line break.
pkg/gui/command_status_panel.go
Outdated
} | ||
|
||
// Update updates the command status panel | ||
func (cs *CommandStatus) Update(ui *Gui) { |
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.
conventionally we use gui as the variable name for *Gui, rather than ui
pkg/gui/commit_message_panel.go
Outdated
|
||
c, isGPG := gui.GitCommand.CommitWithStatus(message) | ||
if isGPG { | ||
// put it into subprogress |
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.
minor typo: this should read subprocess
rather than subprogress
pkg/gui/commit_message_panel.go
Outdated
// put it into subprogress | ||
sub, err := gui.GitCommand.Commit(message) | ||
if err != nil { | ||
// TODO need to find a way to send through this error |
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.
is this TODO still necessary? using an error panel should be fine in my opinion
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 am not sure whether I can remove this, so I just keep it as before.
pkg/gui/command_status_panel.go
Outdated
} | ||
|
||
// Update updates the command status panel | ||
func (cs *CommandStatus) Update(ui *Gui) { |
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 think this could have a better name, something like PrintCommandOutput
. The name Update
suggests to me that it will be an immediate operation
pkg/gui/gui.go
Outdated
@@ -136,6 +142,17 @@ func (gui *Gui) scrollDownMain(g *gocui.Gui, v *gocui.View) error { | |||
return nil | |||
} | |||
|
|||
func (gui *Gui) scrollDownCommandStatus(g *gocui.Gui, v *gocui.View) error { |
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 duplicates some code from the above scroll method. Could we make a generic function that takes a view name and returns a method for scrolling that view? Something like this:
func (gui *Gui) genericScrollDown(viewName string) func(g *gocui.Gui, v *gocui.View) error {
return func (g *gocui.Gui, v *gocui.View) error {
view, err := g.View(viewName)
if err != nil {
return err
}
ox, oy := view.Origin()
if oy < len(view.BufferLines()) {
return view.SetOrigin(ox, oy+gui.Config.GetUserConfig().GetInt("gui.scrollHeight"))
}
return nil
}
}
then in our keybindings file we can use it like so:
}, {
ViewName: "",
Key: gocui.KeyPgdn,
Modifier: gocui.ModNone,
Handler: gui.genericScrollDown("main"),
}, {
return err | ||
isStreamingStatusEnable := gui.Config.GetUserConfig().GetBool("commandStatus") | ||
|
||
if isStreamingStatusEnable { |
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 duplicates some code. The only difference between the two blocks in the if statement is commitsBranchesBoundary
vs optionsTop
, so we can just assign that value to a variable based on the value of isStreamingStatusEnable
and then we don't need to have the SetView method repeated
@@ -217,7 +248,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { | |||
} | |||
filesView.Highlight = true | |||
filesView.Title = gui.Tr.SLocalize("FilesTitle") | |||
v.FgColor = gocui.ColorWhite | |||
filesView.FgColor = gocui.ColorWhite |
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.
good pickup ;)
pkg/gui/gui.go
Outdated
@@ -429,6 +471,13 @@ func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error { | |||
return gui.createUpdateQuitConfirmation(g, v) | |||
} | |||
if gui.Config.GetUserConfig().GetBool("confirmOnQuit") { | |||
// clear command status buffer |
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'm not sure why we're clearing this buffer if we're about to quit anyway
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 is seems unnecessary to do this XD
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.
Cool stuff! I've been using it throughout the week and it seems pretty stable.
I left some comments :)
Thanks for your advice , i will do some code fix this weekend. |
0409387
to
77680d8
Compare
commands: add commit status flags gui: fix commit status gui: fix streaming panel blocking
Hello @jesseduffield , I rebased my code, and pushed again for re-review. (BTW, The package management is the really disappointing thing , when I add my cmd repo in toml, and run |
@scbizu I have a number of questions and comments..
|
@mjarkk Hi, thanks for your reply.
|
Great to hear that the program still work on win :), |
Sounds GREAT XD |
Giving this a quick local test, I've noticed a few things:
|
|
doing a cleanup of PR's so I'm closing this but if you ever want to give it another shot feel free to raise another PR :) |
This PR was looking promising - I'm looking to see the output from a
Am aware of the bitbucket/github integration but the version of bitbucket I'm using uses a different URL structure. Was this PR addressing push output as well, or just commit? Wanting to know whether to raise a separate issue for this. |
Hi @matejcik , this PR does nothing special but only output which
and then the streaming panel will be too . (Since I unfollowed the lazygit ecosystem too long so that maybe this PR is already out-of-date and has no guaranteed deadline) |