MCPcopy
hub / github.com/jesseduffield/lazygit / Start

Function Start

pkg/app/entry_point.go:53–178  ·  view source on GitHub ↗
(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTest)

Source from the content-addressed store, hash-verified

51}
52
53func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTest) {
54 cliArgs := parseCliArgsAndEnvVars()
55 mergeBuildInfo(buildInfo)
56
57 if cliArgs.RepoPath != "" {
58 if cliArgs.WorkTree != "" || cliArgs.GitDir != "" {
59 log.Fatal("--path option is incompatible with the --work-tree and --git-dir options")
60 }
61
62 absRepoPath, err := filepath.Abs(cliArgs.RepoPath)
63 if err != nil {
64 log.Fatal(err)
65 }
66
67 if isRepo, err := isDirectoryAGitRepository(absRepoPath); err != nil || !isRepo {
68 log.Fatal(absRepoPath + " is not a valid git repository.")
69 }
70
71 cliArgs.GitDir = filepath.Join(absRepoPath, ".git")
72 err = os.Chdir(absRepoPath)
73 if err != nil {
74 log.Fatalf("Failed to change directory to %s: %v", absRepoPath, err)
75 }
76 } else if cliArgs.WorkTree != "" {
77 env.SetWorkTreeEnv(cliArgs.WorkTree)
78
79 if err := os.Chdir(cliArgs.WorkTree); err != nil {
80 log.Fatalf("Failed to change directory to %s: %v", cliArgs.WorkTree, err)
81 }
82 }
83
84 if cliArgs.CustomConfigFile != "" {
85 os.Setenv("LG_CONFIG_FILE", cliArgs.CustomConfigFile)
86 }
87
88 if cliArgs.UseConfigDir != "" {
89 os.Setenv("CONFIG_DIR", cliArgs.UseConfigDir)
90 }
91
92 if cliArgs.GitDir != "" {
93 env.SetGitDirEnv(cliArgs.GitDir)
94 }
95
96 if cliArgs.PrintVersionInfo {
97 gitVersion := getGitVersionInfo()
98 fmt.Printf("commit=%s, build date=%s, build source=%s, version=%s, os=%s, arch=%s, git version=%s\n", buildInfo.Commit, buildInfo.Date, buildInfo.BuildSource, buildInfo.Version, runtime.GOOS, runtime.GOARCH, gitVersion)
99 os.Exit(0)
100 }
101
102 if cliArgs.PrintDefaultConfig {
103 var buf bytes.Buffer
104 encoder := yaml.NewEncoder(&buf)
105 err := encoder.Encode(config.GetDefaultConfigForPlatform(runtime.GOOS))
106 if err != nil {
107 log.Fatal(err.Error())
108 }
109 fmt.Printf("%s\n", buf.String())
110 os.Exit(0)

Callers 2

mainFunction · 0.92
mainFunction · 0.92

Calls 15

GetAppStateMethod · 0.95
SaveGlobalUserConfigMethod · 0.95
SetWorkTreeEnvFunction · 0.92
SetGitDirEnvFunction · 0.92
ConfigDirFunction · 0.92
LogPathFunction · 0.92
TailLogsFunction · 0.92
NewAppConfigFunction · 0.92
InDaemonModeFunction · 0.92
HandleFunction · 0.92
parseCliArgsAndEnvVarsFunction · 0.85

Tested by

no test coverage detected