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
hg
import
(
"os"
"os/exec"
)
func
common
(
cmd
*
exec
.
Cmd
)
*
exec
.
Cmd
{
cmd
.
Env
=
append
(
cmd
.
Env
,
os
.
Environ
()
...
)
cmd
.
Env
=
append
(
cmd
.
Env
,
"HGRCPATH=/dev/null"
)
return
cmd
}
func
Init
(
path
string
)
*
exec
.
Cmd
{
return
common
(
exec
.
Command
(
"hg"
,
"init"
,
path
))
}
func
Serve
(
path
string
,
writeable
bool
)
*
exec
.
Cmd
{
args
:=
[]
string
{
"-R"
,
path
,
"serve"
,
"--stdio"
,
}
return
common
(
exec
.
Command
(
"hg"
,
args
...
))
}
func
Add
(
path
string
,
files
...
string
)
*
exec
.
Cmd
{
args
:=
append
([]
string
{
"add"
,
"--cwd"
,
path
},
files
...
)
return
common
(
exec
.
Command
(
"hg"
,
args
...
))
}
func
Commit
(
path
,
username
,
message
string
)
*
exec
.
Cmd
{
args
:=
[]
string
{
"commit"
,
"--cwd"
,
path
,
"--config"
,
"ui.username="
+
username
,
"-m"
,
message
,
}
return
common
(
exec
.
Command
(
"hg"
,
args
...
))
}