Skip to content

Commit 31f5e12

Browse files
committed
print path upon deferred func
Signed-off-by: reggie-k <regina.voloshin@codefresh.io>
1 parent 482570b commit 31f5e12

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

util/exec/exec.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,22 @@ func RunCommandExt(cmd *exec.Cmd, opts CmdOpts) (string, error) {
186186

187187
// Best-effort cleanup of a stale HEAD.lock after the command finishes.
188188
defer func() {
189+
189190
if cmd.Dir == "" {
190191
return
191192
}
192193
lockPath := filepath.Join(cmd.Dir, ".git", "HEAD.lock")
194+
logCtx.WithFields(logrus.Fields{"headLockPath": lockPath}).Info("Checking HEAD.lock presense post-exec")
193195
if _, err := os.Stat(lockPath); err == nil {
194196
// Log and attempt removal; ignore ENOENT races
195197
logCtx.WithFields(logrus.Fields{"headLockPath": lockPath}).Warn("HEAD.lock present post-exec, removing it")
196198
if rmErr := os.Remove(lockPath); rmErr != nil && !os.IsNotExist(rmErr) {
197199
logCtx.WithFields(logrus.Fields{"headLockPath": lockPath}).Warnf("Failed to remove HEAD.lock: %v", rmErr)
198200
}
201+
} else if !os.IsNotExist(err) {
202+
logCtx.WithFields(logrus.Fields{"headLockPath": lockPath}).Warnf("Failed to stat HEAD.lock: %v", err)
203+
} else {
204+
logCtx.WithFields(logrus.Fields{"headLockPath": lockPath}).Info("HEAD.lock not present post-exec")
199205
}
200206
}()
201207

0 commit comments

Comments
 (0)