grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Update setup for new auth. Init and read auth work, but read also grants write at the moment
2019-09-09, Gary Kramlich
7b6de7b2cfd5
Update setup for new auth. Init and read auth work, but read also grants write at the moment
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"
}