| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"os" |
| 6 |
|
| 7 |
"github.com/go-git/go-git/v5" |
| 8 |
"github.com/go-git/go-git/v5/plumbing/serverinfo" |
| 9 |
"github.com/go-git/go-git/v5/storage/filesystem" |
| 10 |
) |
| 11 |
|
| 12 |
// CmdUpdateServerInfo command updates the server info files in the repository. |
| 13 |
// This is used by git http transport (dumb) to generate a list of available |
| 14 |
// refs for the repository. See: |
| 15 |
// https://git-scm.com/docs/git-update-server-info |
| 16 |
type CmdUpdateServerInfo struct { |
| 17 |
cmd |
| 18 |
} |
| 19 |
|
| 20 |
// Usage returns the usage of the command. |
| 21 |
func (CmdUpdateServerInfo) Usage() string { |
| 22 |
return fmt.Sprintf("within a git repository run: %s", os.Args[0]) |
| 23 |
} |
| 24 |
|
| 25 |
// Execute runs the command. |
| 26 |
func (c *CmdUpdateServerInfo) Execute(args []string) error { |
| 27 |
r, err := git.PlainOpen(".") |
| 28 |
if err != nil { |
| 29 |
return err |
| 30 |
} |
| 31 |
|
| 32 |
fs := r.Storer.(*filesystem.Storage).Filesystem() |
| 33 |
return serverinfo.UpdateServerInfo(r.Storer, fs) |
| 34 |
} |