grim/hgkeeper

ignore the build binaries

23 months ago, Gary Kramlich
ef4ae04808d3
ignore the build binaries
package commands
import (
"fmt"
"path/filepath"
"github.com/gliderlabs/ssh"
log "github.com/sirupsen/logrus"
"keep.imfreedom.org/grim/hgkeeper/access"
"keep.imfreedom.org/grim/hgkeeper/hg"
)
type Serve struct {
repoPath string
repoName string
}
func NewServe(reposPath, repoName string) *Serve {
return &Serve{
repoPath: filepath.Join(reposPath, repoName),
repoName: repoName,
}
}
func (s *Serve) Run(session ssh.Session, username string) error {
if !access.CanRead(username, "/"+s.repoName) {
return fmt.Errorf("repository %q not found", s.repoName)
}
writeable := access.CanWrite(username, "/"+s.repoName)
hgcmd := hg.Serve(s.repoPath, writeable)
if err := run(s.repoName, username, hgcmd, session); err != nil {
return err
}
if s.repoName == access.AdminRepo() {
log.Info("admin repo updated, refreshing access control")
return access.Refresh()
}
return nil
}