Turn overview into an inventory across local and server
overview showed dirty and ahead/behind per project, which git can do on its own. mgsh is the only thing that sees both the local base directory and the ssh server, and joining those answers the questions git cannot: which projects were never pushed to the server (candidates for `init`), and which exist there but not on this machine (candidates for `clone`). Both lists are printed after the summary. An unreachable server is reported as such, rather than as "everything is missing". Each row also names the machine that made the last commit and how long ago. That costs nothing: `push` has always stamped "[user@host]" into the commit message, and nothing ever read it back. On a setup spanning several machines it is usually the piece one actually wanted. Rows also show which mirror targets the repository has a remote for, which is local git config and therefore free. The walk is now concurrent and cheaper per project: `git status --porcelain=v2 --branch` yields branch, upstream, ahead/behind and dirty in one subprocess where three were used before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -152,6 +152,22 @@ func sshOut(remote string) ([]string, error) {
|
||||
return lines, err
|
||||
}
|
||||
|
||||
// serverRepoNames lists the bare repositories on the git server, without the
|
||||
// ".git" suffix.
|
||||
func serverRepoNames() ([]string, error) {
|
||||
lines, err := sshOut("/bin/ls .")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out []string
|
||||
for _, ln := range lines {
|
||||
if m := gitDirRe.FindStringSubmatch(strings.TrimSpace(ln)); m != nil {
|
||||
out = append(out, m[1])
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// serverEntryExists reports whether entry is present in the remote directory
|
||||
// path (relative to the git user's home). The error is returned rather than
|
||||
// folded into the bool so a failed lookup is never mistaken for "not there".
|
||||
|
||||
Reference in New Issue
Block a user