Observe original Git objects consistently
This commit is contained in:
@@ -194,18 +194,18 @@ func inspectLocalState(ctx context.Context, repositoryDir string) (localState, e
|
||||
if err != nil {
|
||||
return localState{}, fmt.Errorf("inspect current branch: %w", err)
|
||||
}
|
||||
commitOutput, err := gitOutput(ctx, repositoryDir, "rev-parse", "--verify", "HEAD^{commit}")
|
||||
commit, err := git.CaptureHead(ctx, repositoryDir)
|
||||
if err != nil {
|
||||
return localState{}, fmt.Errorf("capture HEAD commit: %w", err)
|
||||
}
|
||||
statusOutput, err := gitOutput(ctx, repositoryDir, "status", "--porcelain=v1", "--untracked-files=all")
|
||||
status, err := git.WorktreeStatus(ctx, repositoryDir)
|
||||
if err != nil {
|
||||
return localState{}, fmt.Errorf("inspect worktree and index: %w", err)
|
||||
}
|
||||
return localState{
|
||||
branch: strings.TrimSpace(string(branchOutput)),
|
||||
commit: strings.TrimSpace(string(commitOutput)),
|
||||
status: strings.TrimSpace(string(statusOutput)),
|
||||
commit: commit,
|
||||
status: status,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ func gitOutput(ctx context.Context, repositoryDir string, args ...string) ([]byt
|
||||
err := process.Run(ctx, process.Invocation{
|
||||
Args: commandArgs,
|
||||
Dir: repositoryDir,
|
||||
Env: map[string]string{"GIT_NO_REPLACE_OBJECTS": "1"},
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
})
|
||||
@@ -233,6 +234,7 @@ func hasLocalTag(ctx context.Context, repositoryDir, tag string) (bool, error) {
|
||||
err := process.Run(ctx, process.Invocation{
|
||||
Args: []string{"git", "show-ref", "--verify", "--quiet", "refs/tags/" + tag},
|
||||
Dir: repositoryDir,
|
||||
Env: map[string]string{"GIT_NO_REPLACE_OBJECTS": "1"},
|
||||
Stderr: &stderr,
|
||||
})
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user