diff options
-rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.md | 8 | ||||
-rw-r--r-- | .github/ISSUE_TEMPLATE/feature_request.md | 1 | ||||
-rw-r--r-- | main.go | 45 | ||||
-rw-r--r-- | pkg/app/logging.go | 9 | ||||
-rw-r--r-- | pkg/commands/git_commands/rebase.go | 2 | ||||
-rw-r--r-- | pkg/commands/oscommands/cmd_obj_runner.go | 2 | ||||
-rw-r--r-- | pkg/config/app_config.go | 16 | ||||
-rw-r--r-- | pkg/config/dummies.go | 13 |
8 files changed, 56 insertions, 40 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8956e8abc..c3196a0df 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: bug assignees: '' - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -23,10 +23,8 @@ A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. -**Desktop (please complete the following information):** - - OS: [e.g. Windows] - - Lazygit Version [e.g. v0.1.45] - - The last commit id if you built project from sources (run : ```git rev-parse HEAD```) +**Version info:** +_Run `lazygit --version` and paste the result here_ **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 11fc491ef..5f0a04cee 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: enhancement assignees: '' - --- **Is your feature request related to a problem? Please describe.** @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "runtime" + "runtime/debug" "strings" "github.com/integrii/flaggy" @@ -16,17 +17,23 @@ import ( "github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/logs" + "github.com/jesseduffield/lazygit/pkg/utils" yaml "github.com/jesseduffield/yaml" + "github.com/samber/lo" ) +const DEFAULT_VERSION = "unversioned" + var ( commit string - version = "unversioned" + version = DEFAULT_VERSION date string buildSource = "unknown" ) func main() { + updateBuildInfo() + flaggy.DefaultParser.ShowVersionWithVersionFlag = false repoPath := "" @@ -67,6 +74,10 @@ func main() { flaggy.Parse() + if os.Getenv("DEBUG") == "TRUE" { + debuggingFlag = true + } + if repoPath != "" { if workTree != "" || gitDir != "" { log.Fatal("--path option is incompatible with the --work-tree and --git-dir options") @@ -177,3 +188,35 @@ func parseGitArg(gitArg string) types.GitArg { panic("unreachable") } + +func updateBuildInfo() { + // if the version has already been set by build flags then we'll honour that. + // chances are it's something like v0.31.0 which is more informative than a + // commit hash. + if version != DEFAULT_VERSION { + return + } + + buildInfo, ok := debug.ReadBuildInfo() + if !ok { + return + } + + revision, ok := lo.Find(buildInfo.Settings, func(setting debug.BuildSetting) bool { + return setting.Key == "vcs.revision" + }) + if ok { + commit = revision.Value + // if lazygit was built from source we'll show the version as the + // abbreviated commit hash + version = utils.ShortSha(revision.Value) + } + + // if version hasn't been set we assume that neither has the date + time, ok := lo.Find(buildInfo.Settings, func(setting debug.BuildSetting) bool { + return setting.Key == "vcs.time" + }) + if ok { + date = time.Value + } +} diff --git a/pkg/app/logging.go b/pkg/app/logging.go index db59a15d4..7a5eef74e 100644 --- a/pkg/app/logging.go +++ b/pkg/app/logging.go @@ -11,7 +11,7 @@ import ( func newLogger(config config.AppConfigurer) *logrus.Entry { var log *logrus.Logger - if config.GetDebug() || os.Getenv("DEBUG") == "TRUE" { + if config.GetDebug() { log = newDevelopmentLogger() } else { log = newProductionLogger() @@ -21,12 +21,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry { // https://github.com/aybabtme/humanlog log.Formatter = &logrus.JSONFormatter{} - return log.WithFields(logrus.Fields{ - "debug": config.GetDebug(), - "version": config.GetVersion(), - "commit": config.GetCommit(), - "buildDate": config.GetBuildDate(), - }) + return log.WithFields(logrus.Fields{}) } func newProductionLogger() *logrus.Logger { diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index acf1c810b..48a613e41 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -130,7 +130,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo } cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty %s", baseSha) - self.Log.WithField("command", cmdStr).Info("RunCommand") + self.Log.WithField("command", cmdStr).Debug("RunCommand") cmdObj := self.cmd.New(cmdStr) diff --git a/pkg/commands/oscommands/cmd_obj_runner.go b/pkg/commands/oscommands/cmd_obj_runner.go index 8f064032a..8311f9eb7 100644 --- a/pkg/commands/oscommands/cmd_obj_runner.go +++ b/pkg/commands/oscommands/cmd_obj_runner.go @@ -215,7 +215,7 @@ func (self *cmdObjRunner) runAndStreamAux( if cmdObj.ShouldLog() { self.logCmdObj(cmdObj) } - self.log.WithField("command", cmdObj.ToString()).Info("RunCommand") + self.log.WithField("command", cmdObj.ToString()).Debug("RunCommand") cmd := cmdObj.GetCmd() var stderr bytes.Buffer diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 883d0d030..3591166c7 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -15,7 +15,6 @@ import ( type AppConfig struct { Debug bool `long:"debug" env:"DEBUG" default:"false"` Version string `long:"version" env:"VERSION" default:"unversioned"` - Commit string `long:"commit" env:"COMMIT"` BuildDate string `long:"build-date" env:"BUILD_DATE"` Name string `long:"name" env:"NAME" default:"lazygit"` BuildSource string `long:"build-source" env:"BUILD_SOURCE" default:""` @@ -35,8 +34,6 @@ type AppConfigurer interface { // build info GetVersion() string - GetCommit() string - GetBuildDate() string GetName() string GetBuildSource() string @@ -80,10 +77,6 @@ func NewAppConfig( return nil, err } - if os.Getenv("DEBUG") == "TRUE" { - debuggingFlag = true - } - appState, err := loadAppState() if err != nil { return nil, err @@ -92,7 +85,6 @@ func NewAppConfig( appConfig := &AppConfig{ Name: name, Version: version, - Commit: commit, BuildDate: date, Debug: debuggingFlag, BuildSource: buildSource, @@ -183,14 +175,6 @@ func (c *AppConfig) GetVersion() string { return c.Version } -func (c *AppConfig) GetCommit() string { - return c.Commit -} - -func (c *AppConfig) GetBuildDate() string { - return c.BuildDate -} - func (c *AppConfig) GetName() string { return c.Name } diff --git a/pkg/config/dummies.go b/pkg/config/dummies.go index bd973909a..08150c765 100644 --- a/pkg/config/dummies.go +++ b/pkg/config/dummies.go @@ -7,14 +7,11 @@ import ( // NewDummyAppConfig creates a new dummy AppConfig for testing func NewDummyAppConfig() *AppConfig { appConfig := &AppConfig{ - Name: "lazygit", - Version: "unversioned", - Commit: "", - BuildDate: "", - Debug: false, - BuildSource: "", - UserConfig: GetDefaultConfig(), - AppState: &AppState{}, + Name: "lazygit", + Version: "unversioned", + Debug: false, + UserConfig: GetDefaultConfig(), + AppState: &AppState{}, } _ = yaml.Unmarshal([]byte{}, appConfig.AppState) return appConfig |