grim/hgkeeper

f82b7c397849
Move from our custom yaml access setup to casbin
package commands
import (
"fmt"
"path/filepath"
"golang.org/x/crypto/ssh"
"bitbucket.org/rw_grim/hgkeeper/access"
"bitbucket.org/rw_grim/hgkeeper/hg"
)
type Init struct {
repoPath string
repoName string
}
func NewInit(reposPath, repoName string) *Init {
return &Init{
repoPath: filepath.Join(reposPath, repoName),
repoName: repoName,
}
}
func (i *Init) Run(conn ssh.Channel, serverConn *ssh.ServerConn, username string, req *ssh.Request) error {
if !access.CanInit(username, i.repoName) {
return fmt.Errorf("access denied")
}
return run(hg.Init(i.repoPath), conn, serverConn, req)
}
func (i *Init) String() string {
return "hg init"
}