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

numtide / treefmt / 15162093776

21 May 2025 12:24PM UTC coverage: 37.358% (+0.4%) from 36.992%
15162093776

push

github

web-flow
Merge pull request #588 from numtide/fix/default-tree-root-cmd

Fix defaulting of `tree-root-cmd`.

33 of 54 new or added lines in 3 files covered. (61.11%)

1 existing line in 1 file now uncovered.

690 of 1847 relevant lines covered (37.36%)

16.98 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