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

Improve informational printouts in update-all and update #37

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

vdye
Copy link
Collaborator

@vdye vdye commented Mar 23, 2023

Part of #35

This pull request is a fairly light refactor of update-all.go (replacing direct usage of the exec core library with cmd.CommandExecutor) + some slightly more informative logging in both update-all and update.

@vdye vdye added this to the v1.0 milestone Mar 23, 2023
@vdye vdye self-assigned this Mar 23, 2023
@vdye vdye force-pushed the vdye/update-progress-info branch from 08d9f47 to b35e365 Compare March 23, 2023 01:00
Copy link
Collaborator

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thanks for the fast turnaround here. Nice to see your investment in these interfaces paying off.

cmd/git-bundle-server/update-all.go Show resolved Hide resolved
Comment on lines 56 to 67
cmd := exec.Command(exe, subargs...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout

err := cmd.Start()
if err != nil {
return u.logger.Errorf(ctx, "git command failed to start: %w", err)
}

err = cmd.Wait()
exitCode, err := commandExecutor.RunStdout(ctx, exe, subargs...)
if err != nil {
return u.logger.Errorf(ctx, "git command returned a failure: %w", err)
return u.logger.Error(ctx, err)
} else if exitCode != 0 {
return u.logger.Errorf(ctx, "git-bundle-server update exited with status %d", exitCode)
}
fmt.Print("\n")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a bonus, the refactored code is much clearer about what is happening.

vdye added 2 commits March 23, 2023 10:51
Update 'update-all.go' to use 'common.FileSystem' to get the path to the
'git-bundle-server' executable, and use 'cmd.CommandExecutor' to call
'git-bundle-server update'. The use of the common structures eliminate some
duplicate code as well as set up the command to be unit testable in the
future.

Signed-off-by: Victoria Dye <vdye@github.com>
Add and update informational printouts in 'git-bundle-server update' to
inform users more accurately of which step is in progress, as well as
clearly indicate when the update stops early due to a lack of updates from
the remote.

Also add a printout to 'update-all' indicating which route is being updated
at a given time as it loops through all routes.

Signed-off-by: Victoria Dye <vdye@github.com>
@vdye vdye force-pushed the vdye/update-progress-info branch from b35e365 to ff93dbc Compare March 23, 2023 17:51
@vdye vdye merged commit a4f4087 into main Mar 23, 2023
@vdye vdye deleted the vdye/update-progress-info branch March 23, 2023 17:59
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.

2 participants