mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
Merge pull request #2076 from jesseduffield/build-info
This commit is contained in:
commit
4ffc9a5395
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -4,7 +4,6 @@ about: Create a report to help us improve
|
|||||||
title: ''
|
title: ''
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
@ -12,6 +11,7 @@ A clear and concise description of what the bug is.
|
|||||||
|
|
||||||
**To Reproduce**
|
**To Reproduce**
|
||||||
Steps to reproduce the behavior:
|
Steps to reproduce the behavior:
|
||||||
|
|
||||||
1. Go to '...'
|
1. Go to '...'
|
||||||
2. Click on '....'
|
2. Click on '....'
|
||||||
3. Scroll down to '....'
|
3. Scroll down to '....'
|
||||||
@ -23,10 +23,8 @@ A clear and concise description of what you expected to happen.
|
|||||||
**Screenshots**
|
**Screenshots**
|
||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
**Version info:**
|
||||||
- OS: [e.g. Windows]
|
_Run `lazygit --version` and paste the result here_
|
||||||
- Lazygit Version [e.g. v0.1.45]
|
|
||||||
- The last commit id if you built project from sources (run : ```git rev-parse HEAD```)
|
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
|
1
.github/ISSUE_TEMPLATE/feature_request.md
vendored
1
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -4,7 +4,6 @@ about: Suggest an idea for this project
|
|||||||
title: ''
|
title: ''
|
||||||
labels: enhancement
|
labels: enhancement
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
45
main.go
45
main.go
@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/integrii/flaggy"
|
"github.com/integrii/flaggy"
|
||||||
@ -16,17 +17,23 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/env"
|
"github.com/jesseduffield/lazygit/pkg/env"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/logs"
|
"github.com/jesseduffield/lazygit/pkg/logs"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
yaml "github.com/jesseduffield/yaml"
|
yaml "github.com/jesseduffield/yaml"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DEFAULT_VERSION = "unversioned"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
commit string
|
commit string
|
||||||
version = "unversioned"
|
version = DEFAULT_VERSION
|
||||||
date string
|
date string
|
||||||
buildSource = "unknown"
|
buildSource = "unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
updateBuildInfo()
|
||||||
|
|
||||||
flaggy.DefaultParser.ShowVersionWithVersionFlag = false
|
flaggy.DefaultParser.ShowVersionWithVersionFlag = false
|
||||||
|
|
||||||
repoPath := ""
|
repoPath := ""
|
||||||
@ -67,6 +74,10 @@ func main() {
|
|||||||
|
|
||||||
flaggy.Parse()
|
flaggy.Parse()
|
||||||
|
|
||||||
|
if os.Getenv("DEBUG") == "TRUE" {
|
||||||
|
debuggingFlag = true
|
||||||
|
}
|
||||||
|
|
||||||
if repoPath != "" {
|
if repoPath != "" {
|
||||||
if workTree != "" || gitDir != "" {
|
if workTree != "" || gitDir != "" {
|
||||||
log.Fatal("--path option is incompatible with the --work-tree and --git-dir options")
|
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")
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func newLogger(config config.AppConfigurer) *logrus.Entry {
|
func newLogger(config config.AppConfigurer) *logrus.Entry {
|
||||||
var log *logrus.Logger
|
var log *logrus.Logger
|
||||||
if config.GetDebug() || os.Getenv("DEBUG") == "TRUE" {
|
if config.GetDebug() {
|
||||||
log = newDevelopmentLogger()
|
log = newDevelopmentLogger()
|
||||||
} else {
|
} else {
|
||||||
log = newProductionLogger()
|
log = newProductionLogger()
|
||||||
@ -21,12 +21,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
|
|||||||
// https://github.com/aybabtme/humanlog
|
// https://github.com/aybabtme/humanlog
|
||||||
log.Formatter = &logrus.JSONFormatter{}
|
log.Formatter = &logrus.JSONFormatter{}
|
||||||
|
|
||||||
return log.WithFields(logrus.Fields{
|
return log.WithFields(logrus.Fields{})
|
||||||
"debug": config.GetDebug(),
|
|
||||||
"version": config.GetVersion(),
|
|
||||||
"commit": config.GetCommit(),
|
|
||||||
"buildDate": config.GetBuildDate(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProductionLogger() *logrus.Logger {
|
func newProductionLogger() *logrus.Logger {
|
||||||
|
@ -130,7 +130,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty %s", baseSha)
|
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)
|
cmdObj := self.cmd.New(cmdStr)
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ func (self *cmdObjRunner) runAndStreamAux(
|
|||||||
if cmdObj.ShouldLog() {
|
if cmdObj.ShouldLog() {
|
||||||
self.logCmdObj(cmdObj)
|
self.logCmdObj(cmdObj)
|
||||||
}
|
}
|
||||||
self.log.WithField("command", cmdObj.ToString()).Info("RunCommand")
|
self.log.WithField("command", cmdObj.ToString()).Debug("RunCommand")
|
||||||
cmd := cmdObj.GetCmd()
|
cmd := cmdObj.GetCmd()
|
||||||
|
|
||||||
var stderr bytes.Buffer
|
var stderr bytes.Buffer
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
Debug bool `long:"debug" env:"DEBUG" default:"false"`
|
Debug bool `long:"debug" env:"DEBUG" default:"false"`
|
||||||
Version string `long:"version" env:"VERSION" default:"unversioned"`
|
Version string `long:"version" env:"VERSION" default:"unversioned"`
|
||||||
Commit string `long:"commit" env:"COMMIT"`
|
|
||||||
BuildDate string `long:"build-date" env:"BUILD_DATE"`
|
BuildDate string `long:"build-date" env:"BUILD_DATE"`
|
||||||
Name string `long:"name" env:"NAME" default:"lazygit"`
|
Name string `long:"name" env:"NAME" default:"lazygit"`
|
||||||
BuildSource string `long:"build-source" env:"BUILD_SOURCE" default:""`
|
BuildSource string `long:"build-source" env:"BUILD_SOURCE" default:""`
|
||||||
@ -35,8 +34,6 @@ type AppConfigurer interface {
|
|||||||
|
|
||||||
// build info
|
// build info
|
||||||
GetVersion() string
|
GetVersion() string
|
||||||
GetCommit() string
|
|
||||||
GetBuildDate() string
|
|
||||||
GetName() string
|
GetName() string
|
||||||
GetBuildSource() string
|
GetBuildSource() string
|
||||||
|
|
||||||
@ -80,10 +77,6 @@ func NewAppConfig(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("DEBUG") == "TRUE" {
|
|
||||||
debuggingFlag = true
|
|
||||||
}
|
|
||||||
|
|
||||||
appState, err := loadAppState()
|
appState, err := loadAppState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -92,7 +85,6 @@ func NewAppConfig(
|
|||||||
appConfig := &AppConfig{
|
appConfig := &AppConfig{
|
||||||
Name: name,
|
Name: name,
|
||||||
Version: version,
|
Version: version,
|
||||||
Commit: commit,
|
|
||||||
BuildDate: date,
|
BuildDate: date,
|
||||||
Debug: debuggingFlag,
|
Debug: debuggingFlag,
|
||||||
BuildSource: buildSource,
|
BuildSource: buildSource,
|
||||||
@ -183,14 +175,6 @@ func (c *AppConfig) GetVersion() string {
|
|||||||
return c.Version
|
return c.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AppConfig) GetCommit() string {
|
|
||||||
return c.Commit
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *AppConfig) GetBuildDate() string {
|
|
||||||
return c.BuildDate
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *AppConfig) GetName() string {
|
func (c *AppConfig) GetName() string {
|
||||||
return c.Name
|
return c.Name
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,11 @@ import (
|
|||||||
// NewDummyAppConfig creates a new dummy AppConfig for testing
|
// NewDummyAppConfig creates a new dummy AppConfig for testing
|
||||||
func NewDummyAppConfig() *AppConfig {
|
func NewDummyAppConfig() *AppConfig {
|
||||||
appConfig := &AppConfig{
|
appConfig := &AppConfig{
|
||||||
Name: "lazygit",
|
Name: "lazygit",
|
||||||
Version: "unversioned",
|
Version: "unversioned",
|
||||||
Commit: "",
|
Debug: false,
|
||||||
BuildDate: "",
|
UserConfig: GetDefaultConfig(),
|
||||||
Debug: false,
|
AppState: &AppState{},
|
||||||
BuildSource: "",
|
|
||||||
UserConfig: GetDefaultConfig(),
|
|
||||||
AppState: &AppState{},
|
|
||||||
}
|
}
|
||||||
_ = yaml.Unmarshal([]byte{}, appConfig.AppState)
|
_ = yaml.Unmarshal([]byte{}, appConfig.AppState)
|
||||||
return appConfig
|
return appConfig
|
||||||
|
Loading…
Reference in New Issue
Block a user