added some logs and moved where the post request is made

This commit is contained in:
Zac 2018-08-28 11:39:03 -07:00 committed by Thomas Jackson
parent 7f64d79bbe
commit 0eac8fc5cf
1 changed files with 11 additions and 10 deletions

View File

@ -33,7 +33,7 @@ import (
"strconv"
"strings"
"time"
"http"
"net/http"
"github.com/thockin/glogr"
"github.com/thockin/logr"
@ -277,6 +277,16 @@ func updateSymlink(ctx context.Context, gitRoot, link, newDir string) error {
}
log.V(1).Infof("renamed symlink %s to %s", "tmp-link", link)
// If there is a symlink update callback, call it
if len(*flSymlinkUpdatePostUrl) > 0 {
log.V(0).Infof("sending post request to %s", *flSymlinkUpdatePostUrl)
// Send the post request
_, err := http.NewRequest("POST", *flSymlinkUpdatePostUrl, nil)
if err != nil {
return fmt.Errorf("error sending symlink update callback post request: %v", err)
}
}
// Clean up previous worktree
if len(currentDir) > 0 {
if err = os.RemoveAll(currentDir); err != nil {
@ -292,15 +302,6 @@ func updateSymlink(ctx context.Context, gitRoot, link, newDir string) error {
log.V(1).Infof("pruned old worktrees")
}
// If there is a symlink update callback, call it
if len(*flSymlinkUpdateCallback) > 0 {
// Send the post request
resp, err := http.NewRequest("POST", url, nil)
if err != nil {
return fmt.Errorf("error sending symlink update callback post request: %v", err)
}
}
return nil
}