Updated main to add the env var and send a post request
This commit is contained in:
parent
08282abe9d
commit
7f64d79bbe
|
|
@ -33,6 +33,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"http"
|
||||
|
||||
"github.com/thockin/glogr"
|
||||
"github.com/thockin/logr"
|
||||
|
|
@ -61,6 +62,8 @@ var flMaxSyncFailures = flag.Int("max-sync-failures", envInt("GIT_SYNC_MAX_SYNC_
|
|||
"the number of consecutive failures allowed before aborting (the first pull must succeed, -1 disables aborting for any number of failures after the initial sync)")
|
||||
var flChmod = flag.Int("change-permissions", envInt("GIT_SYNC_PERMISSIONS", 0),
|
||||
"the file permissions to apply to the checked-out files")
|
||||
var flSymlinkUpdatePostUrl = flag.String("symlink-update-post-url", envString("GIT_SYNC_SYMLINK_UPDATE_POST_URL", ""),
|
||||
"a command to run when the symlink is updated")
|
||||
|
||||
var flUsername = flag.String("username", envString("GIT_SYNC_USERNAME", ""),
|
||||
"the username to use")
|
||||
|
|
@ -290,6 +293,15 @@ 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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue