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

murex / TCR / 18999741724

01 Nov 2025 04:50PM UTC coverage: 89.694% (-0.07%) from 89.763%
18999741724

push

github

mengdaming
Update dependencies

5274 of 5880 relevant lines covered (89.69%)

1062.76 hits per line

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

96.2
/src/checker/check_git.go
1
/*
2
Copyright (c) 2023 Murex
3

4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10

11
The above copyright notice and this permission notice shall be included in all
12
copies or substantial portions of the Software.
13

14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
SOFTWARE.
21
*/
22

23
package checker
24

25
import (
26
        "strings"
27

28
        "github.com/murex/tcr/checker/model"
29
        "github.com/murex/tcr/params"
30
        "github.com/murex/tcr/vcs/git"
31
)
32

33
var checkGitRunners []checkPointRunner
34

35
func init() {
3✔
36
        checkGitRunners = []checkPointRunner{
3✔
37
                checkGitCommand,
3✔
38
                checkGitConfig,
3✔
39
                checkGitRepository,
3✔
40
                checkGitRemote,
3✔
41
                checkGitAutoPush,
3✔
42
        }
3✔
43
}
3✔
44

45
func checkGitEnvironment(p params.Params) (cg *model.CheckGroup) {
9✔
46
        cg = model.NewCheckGroup("git environment")
9✔
47
        // git environment is checked only when git is the selected VCS
9✔
48
        if strings.ToLower(p.VCS) == git.Name {
18✔
49
                for _, runner := range checkGitRunners {
18✔
50
                        cg.Add(runner(p)...)
9✔
51
                }
9✔
52
        }
53
        return cg
9✔
54
}
55

56
func checkGitCommand(_ params.Params) (cp []model.CheckPoint) {
6✔
57
        if !git.IsGitCommandAvailable() {
9✔
58
                cp = append(cp, model.ErrorCheckPoint("git command was not found on path"))
3✔
59
                return cp
3✔
60
        }
3✔
61
        cp = append(cp, model.OkCheckPoint("git command path is ", git.GetGitCommandPath()))
3✔
62
        cp = append(cp, model.OkCheckPoint("git version is ", git.GetGitCommandVersion()))
3✔
63
        // We could add here a check on git minimum version. No specific need for now.
3✔
64
        return cp
3✔
65
}
66

67
func checkGitConfig(_ params.Params) (cp []model.CheckPoint) {
6✔
68
        if git.GetGitUserName() == "not set" {
9✔
69
                cp = append(cp, model.WarningCheckPoint("git username is not set"))
3✔
70
                return cp
3✔
71
        }
3✔
72
        cp = append(cp, model.OkCheckPoint("git username is ", git.GetGitUserName()))
3✔
73
        return cp
3✔
74
}
75

76
func checkGitRepository(_ params.Params) (cp []model.CheckPoint) {
9✔
77
        if checkEnv.sourceTreeErr != nil {
12✔
78
                cp = append(cp, model.ErrorCheckPoint("cannot retrieve git repository information from base directory name"))
3✔
79
                return cp
3✔
80
        }
3✔
81
        if checkEnv.vcsErr != nil {
9✔
82
                cp = append(cp, model.ErrorCheckPoint(checkEnv.vcsErr))
3✔
83
                return cp
3✔
84
        }
3✔
85
        if checkEnv.vcs == nil {
3✔
86
                cp = append(cp, model.ErrorCheckPoint("git repository not properly initialized"))
×
87
                return cp
×
88
        }
×
89

90
        cp = append(cp, model.OkCheckPoint("git repository root is ", checkEnv.vcs.GetRootDir()))
3✔
91

3✔
92
        cp = append(cp, model.OkCheckPoint("git working branch is ", checkEnv.vcs.GetWorkingBranch()))
3✔
93
        if checkEnv.vcs.IsOnRootBranch() {
6✔
94
                cp = append(cp, model.WarningCheckPoint("running TCR from a root branch is not recommended"))
3✔
95
        }
3✔
96
        return cp
3✔
97
}
98

99
func checkGitRemote(_ params.Params) (cp []model.CheckPoint) {
12✔
100
        if checkEnv.vcs == nil || checkEnv.vcsErr != nil {
15✔
101
                // If git is not properly initialized, no point in trying to go further
3✔
102
                return []model.CheckPoint{}
3✔
103
        }
3✔
104

105
        if !checkEnv.vcs.IsRemoteEnabled() {
12✔
106
                if checkEnv.vcs.GetRemoteName() != "" {
6✔
107
                        cp = append(cp, model.WarningCheckPoint("git remote not found: ", checkEnv.vcs.GetRemoteName()))
3✔
108
                }
3✔
109
                cp = append(cp, model.OkCheckPoint("git remote is disabled: all operations will be done locally"))
3✔
110
                return cp
3✔
111
        }
112

113
        cp = append(cp, model.OkCheckPoint("git remote name is ", checkEnv.vcs.GetRemoteName()))
6✔
114

6✔
115
        if checkEnv.vcs.CheckRemoteAccess() {
9✔
116
                cp = append(cp, model.OkCheckPoint("git remote access seems to be working"))
3✔
117
        } else {
6✔
118
                cp = append(cp, model.ErrorCheckPoint("git remote access does not seem to be working"))
3✔
119
        }
3✔
120
        return cp
6✔
121
}
122

123
func checkGitAutoPush(p params.Params) (cp []model.CheckPoint) {
6✔
124
        if p.AutoPush {
9✔
125
                cp = append(cp, model.OkCheckPoint("git auto-push is turned on: every commit will be pushed to origin"))
3✔
126
        } else {
6✔
127
                cp = append(cp, model.OkCheckPoint("git auto-push is turned off: commits will only be applied locally"))
3✔
128
        }
3✔
129
        return cp
6✔
130
}
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