| 248 | } |
| 249 | |
| 250 | func run(osArgs []string) { |
| 251 | args = osArgs |
| 252 | say.TurnOnDebuggingByArgs(args) |
| 253 | say.Debug(runtime.Version()) |
| 254 | |
| 255 | versionString := gitVersion() |
| 256 | if versionString == "" { |
| 257 | say.Error("'git' command was not found in PATH. It may be not installed. " + |
| 258 | "To learn how to install 'git' refer to https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.") |
| 259 | Exit(1) |
| 260 | } |
| 261 | |
| 262 | currentVersion := parseGitVersion(versionString) |
| 263 | if currentVersion.Less(parseGitVersion(minimumGitVersion)) { |
| 264 | say.Error(fmt.Sprintf("'git' command version '%s' is lower than the required minimum version (%s). "+ |
| 265 | "Please update your 'git' installation!", versionString, minimumGitVersion)) |
| 266 | Exit(1) |
| 267 | } |
| 268 | |
| 269 | projectRootDir := "" |
| 270 | if isGit() { |
| 271 | projectRootDir = gitRootDir() |
| 272 | if !hasCommits() { |
| 273 | say.Error("Git repository does not have any commits yet. Please create an initial commit.") |
| 274 | Exit(1) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | configuration := config.ReadConfiguration(projectRootDir) |
| 279 | say.Debug("Args '" + strings.Join(args, " ") + "'") |
| 280 | currentCliName := currentCliName(args[0]) |
| 281 | if currentCliName != configuration.CliName { |
| 282 | say.Debug("Updating cli name to " + currentCliName) |
| 283 | configuration.CliName = currentCliName |
| 284 | } |
| 285 | |
| 286 | command, parameters, configuration := config.ParseArgs(args, configuration) |
| 287 | say.Debug("command '" + command + "'") |
| 288 | say.Debug("parameters '" + strings.Join(parameters, " ") + "'") |
| 289 | say.Debug("version " + versionNumber) |
| 290 | say.Debug("workingDir '" + workingDir + "'") |
| 291 | |
| 292 | // workaround until we have a better design |
| 293 | if configuration.GitHooksEnabled { |
| 294 | GitPassthroughStderrStdout = true |
| 295 | } |
| 296 | |
| 297 | execute(command, parameters, configuration) |
| 298 | } |
| 299 | |
| 300 | func hasCommits() bool { |
| 301 | commitCount := silentgit("rev-list", "--all", "--count") |