change pre-receive hook from flag to sub-command
--- type: change description: change pre-receive hook from flag to sub-command fingerprint: AN/k4s8msJaAVVOrm8dQPLpb75lPHy/AFEuyicQfbn1W credentials: - type: pgp_signature pub_key_id: 95C46FA6A41148AC body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl6l8CgACgkQlcRvpqQRSKxA2A//Q8oJFH10/HYp38bG6OUem7nIg7+J0uC6jCpsP3P66jHVQ2+U0tQ1zdrlZLrufVPPTrYuFnY3m2qezl47IOQnMw5qLN0/+8/tv2rWvG+1Ffz/dGhn215r7D59bgihPiyBSEZW6l2uty/LBWHyHHOn4TgGsi49BH+E/CdTS1Wk+6eWcJHBMOjrzdzTq3Im75HU7GRkvVlyuX69dW1tNlItmcEJ0moRCoc5WHUwn64RRjlxQMkMMMNtWL2MdW9/fbVDNQHtS8L91bsUcyp2uAQW0xqVzezen3+LNxMuxpIjD/FRB3NEnkEHspeorIYCTYWxWZaQnSYB26vri/LUSpKDPH6kQ4yBexZDfwU1xI6qJARNPpczUdn0XycddXAHhtlig9Vbx0x8Y7CiuKejhMtkcNK2Zvtt+AYVoF2gCeRNBXbRXRTt3WBNyvju3NeiZD17cIi6XIOIFkpm4hFGrdMEjfeZFsUln3Jt445t1Whg3DIl6rgcS/uVpz01c6OZvH05o0JncuvlMU5akd0i+0j1L7+zH38vj3NC8rLpy4ECnnH72yAnvR2TSB7KVtjVZB3o8VAiQPFAaDn0A8vkrf63/jcyiAFhL/Ee8u38richLfzghjCJJ6JVg61OevlQ6tH+zuzH2+5TleCpjESNZZRu9OclfEFeB/AO5qYY4I38RM4= account: mediocregopher
This commit is contained in:
parent
b01fe1524a
commit
422c444a50
@ -16,20 +16,19 @@ import (
|
|||||||
|
|
||||||
func cmdHook(ctx context.Context, cmd *dcmd.Cmd) {
|
func cmdHook(ctx context.Context, cmd *dcmd.Cmd) {
|
||||||
flag := cmd.FlagSet()
|
flag := cmd.FlagSet()
|
||||||
preRcv := flag.Bool("pre-receive", false, "Use dehub as a server-side pre-receive hook")
|
|
||||||
|
|
||||||
var proj proj
|
var proj proj
|
||||||
proj.initFlags(flag)
|
proj.initFlags(flag)
|
||||||
|
|
||||||
cmd.Run(func() (context.Context, error) {
|
body := func() (context.Context, error) {
|
||||||
if !*preRcv {
|
|
||||||
return nil, errors.New("must set the hook type")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := proj.openProj(); err != nil {
|
if err := proj.openProj(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return ctx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.SubCmd("pre-receive", "Use dehub as a server-side pre-receive hook",
|
||||||
|
func(ctx context.Context, cmd *dcmd.Cmd) {
|
||||||
|
cmd.Run(func() (context.Context, error) {
|
||||||
br := bufio.NewReader(os.Stdin)
|
br := bufio.NewReader(os.Stdin)
|
||||||
for {
|
for {
|
||||||
line, err := br.ReadString('\n')
|
line, err := br.ReadString('\n')
|
||||||
@ -60,4 +59,8 @@ func cmdHook(ctx context.Context, cmd *dcmd.Cmd) {
|
|||||||
fmt.Println("All pushed commits have been verified, well done.")
|
fmt.Println("All pushed commits have been verified, well done.")
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
cmd.Run(body)
|
||||||
}
|
}
|
||||||
|
@ -194,9 +194,9 @@ func (proj *Project) initRemotePreReceive(bare bool) error {
|
|||||||
|
|
||||||
var preRcvBody string
|
var preRcvBody string
|
||||||
if bare {
|
if bare {
|
||||||
preRcvBody = "#!/bin/sh\nexec dehub hook -bare -pre-receive\n"
|
preRcvBody = "#!/bin/sh\nexec dehub hook -bare pre-receive\n"
|
||||||
} else {
|
} else {
|
||||||
preRcvBody = "#!/bin/sh\nexec dehub hook -pre-receive\n"
|
preRcvBody = "#!/bin/sh\nexec dehub hook pre-receive\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := io.Copy(preRcv, bytes.NewBufferString(preRcvBody)); err != nil {
|
if _, err := io.Copy(preRcv, bytes.NewBufferString(preRcvBody)); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user