aboutsummaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/go-git/main.go1
-rw-r--r--cli/go-git/update_server_info.go34
2 files changed, 35 insertions, 0 deletions
diff --git a/cli/go-git/main.go b/cli/go-git/main.go
index 97b8c3e..0a5ad2c 100644
--- a/cli/go-git/main.go
+++ b/cli/go-git/main.go
@@ -22,6 +22,7 @@ func main() {
}
parser := flags.NewNamedParser(bin, flags.Default)
+ parser.AddCommand("update-server-info", "", "", &CmdUpdateServerInfo{})
parser.AddCommand("receive-pack", "", "", &CmdReceivePack{})
parser.AddCommand("upload-pack", "", "", &CmdUploadPack{})
parser.AddCommand("version", "Show the version information.", "", &CmdVersion{})
diff --git a/cli/go-git/update_server_info.go b/cli/go-git/update_server_info.go
new file mode 100644
index 0000000..a7f3e3e
--- /dev/null
+++ b/cli/go-git/update_server_info.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/go-git/go-git/v5"
+ "github.com/go-git/go-git/v5/plumbing/serverinfo"
+ "github.com/go-git/go-git/v5/storage/filesystem"
+)
+
+// CmdUpdateServerInfo command updates the server info files in the repository.
+// This is used by git http transport (dumb) to generate a list of available
+// refs for the repository. See:
+// https://git-scm.com/docs/git-update-server-info
+type CmdUpdateServerInfo struct {
+ cmd
+}
+
+// Usage returns the usage of the command.
+func (CmdUpdateServerInfo) Usage() string {
+ return fmt.Sprintf("within a git repository run: %s", os.Args[0])
+}
+
+// Execute runs the command.
+func (c *CmdUpdateServerInfo) Execute(args []string) error {
+ r, err := git.PlainOpen(".")
+ if err != nil {
+ return err
+ }
+
+ fs := r.Storer.(*filesystem.Storage).Filesystem()
+ return serverinfo.UpdateServerInfo(r.Storer, fs)
+}