mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-27 19:43:34 +00:00
fix: uc deploy should not crash in empty git repository (#275)
Co-authored-by: Anton Ovchinnikov <anton@tonyo.info>
This commit is contained in:
co-authored by
Anton Ovchinnikov
parent
d2703cbc6b
commit
442f1d97a1
@@ -36,10 +36,12 @@ func InspectGitState(dir string) (GitState, error) {
|
||||
return state, nil
|
||||
}
|
||||
|
||||
// Get the current commit SHA.
|
||||
sha, err := gitCommand(dir, "rev-parse", "HEAD")
|
||||
// Get the current commit SHA. An initialised but empty repo has no HEAD yet,
|
||||
// so treat it as a non-repo so callers can fall back to non-git logic.
|
||||
sha, err := gitCommand(dir, "rev-parse", "--verify", "HEAD")
|
||||
if err != nil {
|
||||
return state, fmt.Errorf("get current commit SHA: %w", err)
|
||||
state.IsRepo = false
|
||||
return state, nil
|
||||
}
|
||||
state.SHA = strings.TrimSpace(sha)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user