From 0eac8fc5cfea808c95f720c833d6a69b539c3450 Mon Sep 17 00:00:00 2001 From: Zac Date: Tue, 28 Aug 2018 11:39:03 -0700 Subject: [PATCH] added some logs and moved where the post request is made --- cmd/git-sync/main.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 403c5fb..32eb849 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -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 }