Honor cancellation throughout publication recovery Git operations
This commit is contained in:
@@ -73,6 +73,28 @@ func MetadataDirectories(ctx context.Context, directory string) ([]string, error
|
||||
return directories, nil
|
||||
}
|
||||
|
||||
// CommonDirectory resolves the shared Git metadata directory.
|
||||
func CommonDirectory(ctx context.Context, directory string) (string, error) {
|
||||
output, err := run(ctx, directory, nil, "rev-parse", "--path-format=absolute", "--git-common-dir")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("resolve shared Git metadata directory: %w", err)
|
||||
}
|
||||
return normalizeRepositoryRoot(output)
|
||||
}
|
||||
|
||||
// IsIgnored checks whether Git excludes the selected worktree path.
|
||||
func IsIgnored(ctx context.Context, directory, path string) (bool, error) {
|
||||
_, err := run(ctx, directory, nil, "check-ignore", "-q", "--", path)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
var exitErr *exec.ExitError
|
||||
if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
// DiscoverRepositoryRoot finds a containing checkout or confirms standalone use.
|
||||
func DiscoverRepositoryRoot(ctx context.Context, directory string) (string, bool, error) {
|
||||
if directory == "" {
|
||||
|
||||
Reference in New Issue
Block a user