-
Notifications
You must be signed in to change notification settings - Fork 23
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
git-bundle-server
CLI Part 2: collapse base bundle and the update-all
subcommand
#3
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f9fe205
bundles: fix bundle parsing
derrickstolee 501f64f
update: collapse list if it grows longer than 5 items
derrickstolee 8a0e1a1
core: create concept of routes file
derrickstolee 1f32d18
README: fix 'update-all' mention
derrickstolee 8a86545
update-all: create update-all subcommand
derrickstolee 3d0746a
update-all: pass all args down to 'update' subcommand
derrickstolee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ func all() []Subcommand { | |
return []Subcommand{ | ||
Init{}, | ||
Update{}, | ||
UpdateAll{}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"git-bundle-server/internal/core" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
type UpdateAll struct{} | ||
|
||
func (UpdateAll) subcommand() string { | ||
return "update-all" | ||
} | ||
|
||
func (UpdateAll) run(args []string) error { | ||
exe, err := os.Executable() | ||
if err != nil { | ||
return fmt.Errorf("failed to get path to execuable: %w", err) | ||
} | ||
|
||
repos, err := core.GetRepositories() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
subargs := []string{"update", ""} | ||
subargs = append(subargs, args...) | ||
|
||
for route := range repos { | ||
subargs[1] = route | ||
cmd := exec.Command(exe, subargs...) | ||
cmd.Stderr = os.Stderr | ||
cmd.Stdout = os.Stdout | ||
|
||
err := cmd.Start() | ||
if err != nil { | ||
return fmt.Errorf("git command failed to start: %w", err) | ||
} | ||
|
||
err = cmd.Wait() | ||
if err != nil { | ||
return fmt.Errorf("git command returned a failure: %w", err) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 know I mentioned this offline, but mentioning it here too..
Having
update-all
as a separate subcommand that calls out toupdate
in a loop will mean paying some cost to fork+exec, and possibly and other process setup, config, tracing etc.Would the
update --all
loop being in the same subcommand (or evenupdate-all
that leverages the sameupdate
functions in a loop) not be preferable here?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 for now, the fact that
<route>
is a positional argument in the CLI makes me not want to swap this. Keep in mind that we are also spawninggit fetch
subcommands at minimum andgit bundle create
if there is new data, so the process startup cost is very small compared to what commands we are running under the hood.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've attempted the rewrite of
update-all
asupdate --all
in this branch, but I'm again having local build issues (:old-man-shakes-fist-at-go:
).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.
Of course the build issues come from the fact that I removed the
go.work
workspace file and all of thego.mod
files throughout my workspace. So... they are somehow critical to how I was able to get things working.