-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3:
git-bundle-server
CLI Part 2: collapse base …
…bundle and the `update-all` subcommand Based on #2. The `update` subcommand now notices when there are more than 5 bundles and squashes the oldest ones into a new "base" bundle. The bundle is renamed but keeps the maximum creation token from that group of bundles. Modified some of the parameters, especially those in the `git` package to avoid cyclic package dependencies. Also used struct pointers more often. Repository routes are now stored in a new `routes` file (currently plaintext with line-separated list of routes). The new `update-all` subcommand runs the `update` subcommand on all registered routes. It also passes any remaining arguments down to the subcommand, which will help when we add the `--daily` and `--hourly` options.
- Loading branch information
Showing
8 changed files
with
284 additions
and
52 deletions.
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.