grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
access.yml is no longer used for out authentication, also not sure how this ended up here...
2019-09-11, Gary Kramlich
2664db87766e
access.yml is no longer used for out authentication, also not sure how this ended up here...
package
commands
import
(
"fmt"
"path/filepath"
"golang.org/x/crypto/ssh"
"bitbucket.org/rw_grim/hgkeeper/access"
"bitbucket.org/rw_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
(
conn
ssh
.
Channel
,
serverConn
*
ssh
.
ServerConn
,
username
string
,
req
*
ssh
.
Request
)
error
{
if
!
access
.
CanRead
(
username
,
"/"
+
s
.
repoName
)
{
return
fmt
.
Errorf
(
"repository %q not found"
,
s
.
repoName
)
}
writeable
:=
access
.
CanWrite
(
username
,
"/"
+
s
.
repoName
)
return
run
(
hg
.
Serve
(
s
.
repoPath
,
writeable
),
conn
,
serverConn
,
req
)
}
func
(
s
*
Serve
)
String
()
string
{
return
"hg serve"
}