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

numtide / treefmt / 15109345722

19 May 2025 09:27AM UTC coverage: 36.933% (-0.06%) from 36.992%
15109345722

Pull #588

github

brianmcgee
docs: add `tree-root-cmd` in usage section

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

22 of 42 new or added lines in 3 files covered. (52.38%)

1 existing line in 1 file now uncovered.

684 of 1852 relevant lines covered (36.93%)

17.18 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