• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

numtide / treefmt / 15132031900

20 May 2025 07:56AM UTC coverage: 37.228% (+0.2%) from 36.992%
15132031900

Pull #588

github

brianmcgee
fixup! fix: better logic for tree-root-cmd defaulting when walk is auto

Signed-off-by: Brian McGee <brian@bmcgee.ie>
Pull Request #588: Fix defaulting of `tree-root-cmd`.

19 of 38 new or added lines in 3 files covered. (50.0%)

1 existing line in 1 file now uncovered.

685 of 1840 relevant lines covered (37.23%)

17.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/git/git.go
1
package git
2

3
import (
4
        "errors"
5
        "fmt"
6
        "os/exec"
7
        "strings"
8
)
9

10
const TreeRootCmd = "git rev-parse --show-toplevel"
11

NEW
12
func IsInsideWorktree(path string) (bool, error) {
×
NEW
13
        // check if the root is a git repository
×
NEW
14
        cmd := exec.Command("git", "rev-parse", "--is-inside-work-tree")
×
NEW
15
        cmd.Dir = path
×
NEW
16

×
NEW
17
        out, err := cmd.Output()
×
NEW
18
        if err != nil {
×
NEW
19
                var exitErr *exec.ExitError
×
NEW
20
                if errors.As(err, &exitErr) && strings.Contains(string(exitErr.Stderr), "not a git repository") {
×
NEW
21
                        return false, nil
×
NEW
22
                }
×
23

NEW
24
                return false, fmt.Errorf("failed to check if %s is a git repository: %w", path, err)
×
25
        }
26

NEW
27
        if strings.Trim(string(out), "\n") != "true" {
×
NEW
28
                // not a git repo
×
NEW
29
                return false, nil
×
NEW
30
        }
×
31

32
        // is a git repo
NEW
33
        return true, nil
×
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc