1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-18 05:17:55 +02:00

add random tip to command log

This commit is contained in:
Jesse Duffield 2021-04-11 23:32:20 +10:00
parent 06a8eb115c
commit 3b7e7a7f56
12 changed files with 213 additions and 33 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/integrii/flaggy" "github.com/integrii/flaggy"
"github.com/jesseduffield/lazygit/pkg/app" "github.com/jesseduffield/lazygit/pkg/app"
"github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/env"
yaml "github.com/jesseduffield/yaml" yaml "github.com/jesseduffield/yaml"
) )
@ -134,6 +135,6 @@ func main() {
stackTrace := newErr.ErrorStack() stackTrace := newErr.ErrorStack()
app.Log.Error(stackTrace) app.Log.Error(stackTrace)
log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.ErrorOccurred, stackTrace)) log.Fatal(fmt.Sprintf("%s: %s\n\n%s", app.Tr.ErrorOccurred, constants.Links.Issues, stackTrace))
} }
} }

View File

@ -103,6 +103,7 @@ type KeybindingConfig struct {
Submodules KeybindingSubmodulesConfig `yaml:"submodules"` Submodules KeybindingSubmodulesConfig `yaml:"submodules"`
} }
// damn looks like we have some inconsistencies here with -alt and -alt1
type KeybindingUniversalConfig struct { type KeybindingUniversalConfig struct {
Quit string `yaml:"quit"` Quit string `yaml:"quit"`
QuitAlt1 string `yaml:"quit-alt1"` QuitAlt1 string `yaml:"quit-alt1"`
@ -121,6 +122,8 @@ type KeybindingUniversalConfig struct {
NextBlock string `yaml:"nextBlock"` NextBlock string `yaml:"nextBlock"`
PrevBlockAlt string `yaml:"prevBlock-alt"` PrevBlockAlt string `yaml:"prevBlock-alt"`
NextBlockAlt string `yaml:"nextBlock-alt"` NextBlockAlt string `yaml:"nextBlock-alt"`
NextBlockAlt2 string `yaml:"nextBlock-alt2"`
PrevBlockAlt2 string `yaml:"prevBlock-alt2"`
NextMatch string `yaml:"nextMatch"` NextMatch string `yaml:"nextMatch"`
PrevMatch string `yaml:"prevMatch"` PrevMatch string `yaml:"prevMatch"`
StartSearch string `yaml:"startSearch"` StartSearch string `yaml:"startSearch"`
@ -352,6 +355,8 @@ func GetDefaultConfig() *UserConfig {
NextBlock: "<right>", NextBlock: "<right>",
PrevBlockAlt: "h", PrevBlockAlt: "h",
NextBlockAlt: "l", NextBlockAlt: "l",
PrevBlockAlt2: "<backtab>",
NextBlockAlt2: "<tab>",
NextMatch: "n", NextMatch: "n",
PrevMatch: "N", PrevMatch: "N",
StartSearch: "/", StartSearch: "/",

33
pkg/constants/links.go Normal file
View File

@ -0,0 +1,33 @@
package constants
type Docs struct {
CustomPagers string
CustomCommands string
CustomKeybindings string
Keybindings string
Undoing string
Config string
Tutorial string
}
var Links = struct {
Docs Docs
Issues string
Donate string
Discussions string
RepoUrl string
}{
RepoUrl: "https://github.com/jesseduffield/lazygit",
Issues: "https://github.com/jesseduffield/lazygit/issues",
Donate: "https://github.com/sponsors/jesseduffield",
Discussions: "https://github.com/jesseduffield/lazygit/discussions",
Docs: Docs{
CustomPagers: "https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_Pagers.md",
CustomKeybindings: "https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md",
CustomCommands: "https://github.com/jesseduffield/lazygit/wiki/Custom-Commands-Compendium",
Keybindings: "https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings",
Undoing: "https://github.com/jesseduffield/lazygit/blob/master/docs/Undoing.md",
Config: "https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md",
Tutorial: "https://youtu.be/VDXvbHZYeKY",
},
}

View File

@ -2,10 +2,13 @@ package gui
import ( import (
"fmt" "fmt"
"math/rand"
"strings" "strings"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
) )
@ -35,3 +38,148 @@ func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
fmt.Fprint(gui.Views.Extras, "\n"+utils.ColoredString(indentedCmdStr, clrAttr)) fmt.Fprint(gui.Views.Extras, "\n"+utils.ColoredString(indentedCmdStr, clrAttr))
} }
} }
func (gui *Gui) printCommandLogHeader() {
introStr := fmt.Sprintf(
gui.Tr.CommandLogHeader,
gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.ExtrasMenu),
)
fmt.Fprintln(gui.Views.Extras, utils.ColoredString(introStr, color.FgCyan))
fmt.Fprint(
gui.Views.Extras,
fmt.Sprintf(
"%s: %s",
utils.ColoredString(gui.Tr.RandomTip, color.FgYellow),
utils.ColoredString(gui.getRandomTip(), color.FgGreen),
),
)
}
func (gui *Gui) getRandomTip() string {
config := gui.Config.GetUserConfig().Keybinding
formattedKey := func(key string) string {
return gui.getKeyDisplay(key)
}
tips := []string{
// keybindings and lazygit-specific advice
fmt.Sprintf(
"To force push, press '%s' and then if the push is rejected you will be asked if you want to force push",
formattedKey(config.Universal.PushFiles),
),
fmt.Sprintf(
"To filter commits by path, press '%s'",
formattedKey(config.Universal.FilteringMenu),
),
fmt.Sprintf(
"To start an interactive rebase, press '%s' on a commit. You can always abort the rebase by pressing '%s' and selecting 'abort'",
formattedKey(config.Universal.Edit),
formattedKey(config.Universal.CreateRebaseOptionsMenu),
),
fmt.Sprintf(
"In flat file view, merge conflicts are sorted to the top. To switch to flat file view press '%s'",
formattedKey(config.Files.ToggleTreeView),
),
"If you want to learn Go and can think of ways to improve lazygit, join the team! Click 'Ask Question' and express your interest",
fmt.Sprintf(
"If you press '%s'/'%s' you can undo/redo your changes. Be wary though, this only applies to branches/commits, so only do this if your worktree is clear.\nDocs: %s",
formattedKey(config.Universal.Undo),
formattedKey(config.Universal.Redo),
constants.Links.Docs.Undoing,
),
fmt.Sprintf(
"to hard reset onto your current upstream branch, press '%s' in the files panel",
formattedKey(config.Files.ViewResetOptions),
),
fmt.Sprintf(
"To push a tag, navigate to the tag in the tags tab and press '%s'",
formattedKey(config.Branches.PushTag),
),
fmt.Sprintf(
"You can view the individual files of a stash entry by pressing '%s'",
formattedKey(config.Universal.GoInto),
),
fmt.Sprintf(
"You can diff two commits by pressing '%s' one one commit and then navigating to the other. You can then press '%s' to view the files of the diff",
formattedKey(config.Universal.DiffingMenu),
formattedKey(config.Universal.GoInto),
),
fmt.Sprintf(
"press '%s' on a commit to drop it (delete it)",
formattedKey(config.Universal.Remove),
),
fmt.Sprintf(
"If you need to pull out the big guns to resolve merge conflicts, you can press '%s' in the files panel to open 'git mergetool'",
formattedKey(config.Files.OpenMergeTool),
),
fmt.Sprintf(
"To revert a commit, press '%s' on that commit",
formattedKey(config.Commits.RevertCommit),
),
fmt.Sprintf(
"To escape a mode, for example cherry-picking, patch-building, diffing, or filtering mode, you can just spam the '%s' button. Unless of course you have `quitOnTopLevelReturn` enabled in your config",
formattedKey(config.Universal.Return),
),
fmt.Sprintf(
"To search for a string in your panel, press '%s'",
formattedKey(config.Universal.StartSearch),
),
fmt.Sprintf(
"You can page through the items of a panel using '%s' and '%s'",
formattedKey(config.Universal.PrevPage),
formattedKey(config.Universal.NextPage),
),
fmt.Sprintf(
"You can jump to the top/bottom of a panel using '%s' and '%s'",
formattedKey(config.Universal.GotoTop),
formattedKey(config.Universal.GotoBottom),
),
fmt.Sprintf(
"To collapse/expand a directory, press '%s'",
formattedKey(config.Universal.GoInto),
),
fmt.Sprintf(
"You can append your staged changes to an older commit by pressing '%s' on that commit",
formattedKey(config.Commits.AmendToCommit),
),
fmt.Sprintf(
"You can amend the last commit with your new file changes by pressing '%s' in the files panel",
formattedKey(config.Files.AmendLastCommit),
),
fmt.Sprintf(
"You can now navigate the side panels with '%s' and '%s'",
formattedKey(config.Universal.NextBlockAlt2),
formattedKey(config.Universal.PrevBlockAlt2),
),
"You can use lazygit with a bare repo by passing the --git-dir and --work-tree arguments as you would for the git CLI",
// general advice
"`git commit` is really just the programmer equivalent of saving your game. Always do it before embarking on an ambitious change!",
"Try to separate commits that refactor code from commits that add new functionality: if they're squashed into the one commit, it can be hard to spot what's new.",
"If you ever want to experiment, it's easy to create a new branch off your current one and go nuts, then delete it afterwards",
"Always read through the diff of your changes before assigning somebody to review your code. Better for you to catch any silly mistakes than your colleagues!",
"If something goes wrong, you can always checkout a commit from your reflog to return to an earlier state",
"The stash is a good place to save snippets of code that you always find yourself adding when debugging.",
// links
fmt.Sprintf(
"If you want a git diff with syntax colouring, check out lazygit's integration with delta:\n%s",
constants.Links.Docs.CustomPagers,
),
fmt.Sprintf(
"You can build your own custom menus and commands to run from within lazygit. For examples see:\n%s",
constants.Links.Docs.CustomCommands,
),
fmt.Sprintf(
"If you ever find a bug, do not hesistate to raise an issue on the repo:\n%s",
constants.Links.Issues,
),
}
rand.Seed(time.Now().UnixNano())
randomIndex := rand.Intn(len(tips))
return tips[randomIndex]
}

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/constants"
) )
func (gui *Gui) informationStr() string { func (gui *Gui) informationStr() string {
@ -43,9 +44,9 @@ func (gui *Gui) handleInfoClick() error {
// if we're not in an active mode we show the donate button // if we're not in an active mode we show the donate button
if cx <= len(gui.Tr.Donate) { if cx <= len(gui.Tr.Donate) {
return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield") return gui.OSCommand.OpenLink(constants.Links.Donate)
} else if cx <= len(gui.Tr.Donate)+1+len(gui.Tr.AskQuestion) { } else if cx <= len(gui.Tr.Donate)+1+len(gui.Tr.AskQuestion) {
return gui.OSCommand.OpenLink("https://github.com/jesseduffield/lazygit/discussions") return gui.OSCommand.OpenLink(constants.Links.Discussions)
} }
return nil return nil
} }

View File

@ -8,6 +8,7 @@ import (
"unicode/utf8" "unicode/utf8"
"github.com/jesseduffield/gocui" "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/constants"
) )
// Binding - a keybinding mapping a key and modifier to a handler. The keypress // Binding - a keybinding mapping a key and modifier to a handler. The keypress
@ -53,7 +54,8 @@ var keyMapReversed = map[gocui.Key]string{
gocui.KeyArrowDown: "▼", gocui.KeyArrowDown: "▼",
gocui.KeyArrowLeft: "◄", gocui.KeyArrowLeft: "◄",
gocui.KeyArrowRight: "►", gocui.KeyArrowRight: "►",
gocui.KeyTab: "tab", // ctrl+i gocui.KeyTab: "tab", // ctrl+i
gocui.KeyBacktab: "shift+tab",
gocui.KeyEnter: "enter", // ctrl+m gocui.KeyEnter: "enter", // ctrl+m
gocui.KeyAltEnter: "alt+enter", gocui.KeyAltEnter: "alt+enter",
gocui.KeyEsc: "esc", // ctrl+[, ctrl+3 gocui.KeyEsc: "esc", // ctrl+[, ctrl+3
@ -133,6 +135,7 @@ var keymap = map[string]interface{}{
"<c-_>": gocui.KeyCtrlUnderscore, "<c-_>": gocui.KeyCtrlUnderscore,
"<backspace>": gocui.KeyBackspace, "<backspace>": gocui.KeyBackspace,
"<tab>": gocui.KeyTab, "<tab>": gocui.KeyTab,
"<backtab>": gocui.KeyBacktab,
"<enter>": gocui.KeyEnter, "<enter>": gocui.KeyEnter,
"<a-enter>": gocui.KeyAltEnter, "<a-enter>": gocui.KeyAltEnter,
"<esc>": gocui.KeyEsc, "<esc>": gocui.KeyEsc,
@ -188,7 +191,7 @@ func (gui *Gui) getKey(key string) interface{} {
if runeCount > 1 { if runeCount > 1 {
binding := keymap[strings.ToLower(key)] binding := keymap[strings.ToLower(key)]
if binding == nil { if binding == nil {
log.Fatalf("Unrecognized key %s for keybinding. For permitted values see https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md", strings.ToLower(key)) log.Fatalf("Unrecognized key %s for keybinding. For permitted values see %s", strings.ToLower(key), constants.Links.Docs.CustomKeybindings)
} else { } else {
return binding return binding
} }
@ -1773,8 +1776,8 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{ViewName: viewName, Key: gui.getKey(config.Universal.NextBlock), Modifier: gocui.ModNone, Handler: gui.nextSideWindow}, {ViewName: viewName, Key: gui.getKey(config.Universal.NextBlock), Modifier: gocui.ModNone, Handler: gui.nextSideWindow},
{ViewName: viewName, Key: gui.getKey(config.Universal.PrevBlockAlt), Modifier: gocui.ModNone, Handler: gui.previousSideWindow}, {ViewName: viewName, Key: gui.getKey(config.Universal.PrevBlockAlt), Modifier: gocui.ModNone, Handler: gui.previousSideWindow},
{ViewName: viewName, Key: gui.getKey(config.Universal.NextBlockAlt), Modifier: gocui.ModNone, Handler: gui.nextSideWindow}, {ViewName: viewName, Key: gui.getKey(config.Universal.NextBlockAlt), Modifier: gocui.ModNone, Handler: gui.nextSideWindow},
{ViewName: viewName, Key: gocui.KeyBacktab, Modifier: gocui.ModNone, Handler: gui.previousSideWindow}, {ViewName: viewName, Key: gui.getKey(config.Universal.PrevBlockAlt2), Modifier: gocui.ModNone, Handler: gui.previousSideWindow},
{ViewName: viewName, Key: gocui.KeyTab, Modifier: gocui.ModNone, Handler: gui.nextSideWindow}, {ViewName: viewName, Key: gui.getKey(config.Universal.NextBlockAlt2), Modifier: gocui.ModNone, Handler: gui.nextSideWindow},
}...) }...)
} }

View File

@ -1,12 +1,8 @@
package gui package gui
import ( import (
"fmt"
"github.com/fatih/color"
"github.com/jesseduffield/gocui" "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
) )
const SEARCH_PREFIX = "search: " const SEARCH_PREFIX = "search: "
@ -125,6 +121,7 @@ func (gui *Gui) createAllViews() error {
gui.Views.Extras.Title = gui.Tr.CommandLog gui.Views.Extras.Title = gui.Tr.CommandLog
gui.Views.Extras.FgColor = theme.GocuiDefaultTextColor gui.Views.Extras.FgColor = theme.GocuiDefaultTextColor
gui.Views.Extras.Autoscroll = true gui.Views.Extras.Autoscroll = true
gui.Views.Extras.Wrap = true
gui.printCommandLogHeader() gui.printCommandLogHeader()
if _, err := gui.g.SetCurrentView(gui.defaultSideContext().GetViewName()); err != nil { if _, err := gui.g.SetCurrentView(gui.defaultSideContext().GetViewName()); err != nil {
@ -134,14 +131,6 @@ func (gui *Gui) createAllViews() error {
return nil return nil
} }
func (gui *Gui) printCommandLogHeader() {
introStr := fmt.Sprintf(
gui.Tr.CommandLogHeader,
gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.ExtrasMenu),
)
fmt.Fprintln(gui.Views.Extras, utils.ColoredString(introStr, color.FgCyan))
}
// layout is called for every screen re-render e.g. when the screen is resized // layout is called for every screen re-render e.g. when the screen is resized
func (gui *Gui) layout(g *gocui.Gui) error { func (gui *Gui) layout(g *gocui.Gui) error {
if !gui.ViewsSetup { if !gui.ViewsSetup {

View File

@ -6,6 +6,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
) )
@ -106,11 +107,11 @@ func (gui *Gui) handleStatusSelect() error {
[]string{ []string{
lazygitTitle(), lazygitTitle(),
"Copyright (c) 2018 Jesse Duffield", "Copyright (c) 2018 Jesse Duffield",
"Keybindings: https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings", fmt.Sprintf("Keybindings: %s", constants.Links.Docs.Keybindings),
"Config Options: https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md", fmt.Sprintf("Config Options: %s", constants.Links.Docs.Config),
"Tutorial: https://youtu.be/VDXvbHZYeKY", fmt.Sprintf("Tutorial: %s", constants.Links.Docs.Tutorial),
"Raise an Issue: https://github.com/jesseduffield/lazygit/issues", fmt.Sprintf("Raise an Issue: %s", constants.Links.Issues),
magenta.Sprint("Become a sponsor (github is matching all donations for 12 months): https://github.com/sponsors/jesseduffield"), // caffeine ain't free magenta.Sprintf("Become a sponsor (github is matching all donations for 12 months): %s", constants.Links.Donate), // caffeine ain't free
gui.Tr.ReleaseNotes, gui.Tr.ReleaseNotes,
}, "\n\n") }, "\n\n")

View File

@ -207,7 +207,7 @@ func dutchTranslationSet() TranslationSet {
ConfirmMerge: "Weet je zeker dat je {{.selectedBranch}} in {{.checkedOutBranch}} wil mergen?", ConfirmMerge: "Weet je zeker dat je {{.selectedBranch}} in {{.checkedOutBranch}} wil mergen?",
FwdNoUpstream: "Kan niet de branch vooruitspoelen zonder upstream", FwdNoUpstream: "Kan niet de branch vooruitspoelen zonder upstream",
FwdCommitsToPush: "Je kan niet vooruitspoelen als de branch geen nieuwe commits heeft", FwdCommitsToPush: "Je kan niet vooruitspoelen als de branch geen nieuwe commits heeft",
ErrorOccurred: "Er is iets fout gegaan! Zou je hier een issue aan willen maken: https://github.com/jesseduffield/lazygit/issues", ErrorOccurred: "Er is iets fout gegaan! Zou je hier een issue aan willen maken",
NoRoom: "Niet genoeg ruimte", NoRoom: "Niet genoeg ruimte",
YouAreHere: "JE BENT HIER", YouAreHere: "JE BENT HIER",
LcRewordNotSupported: "herformatteren van commits in interactief rebasen is nog niet ondersteund", LcRewordNotSupported: "herformatteren van commits in interactief rebasen is nog niet ondersteund",

View File

@ -449,6 +449,7 @@ type TranslationSet struct {
ToggleShowCommandLog string ToggleShowCommandLog string
FocusCommandLog string FocusCommandLog string
CommandLogHeader string CommandLogHeader string
RandomTip string
Spans Spans Spans Spans
} }
@ -960,7 +961,7 @@ func englishTranslationSet() TranslationSet {
ConfirmMerge: "Are you sure you want to merge {{.selectedBranch}} into {{.checkedOutBranch}}?", ConfirmMerge: "Are you sure you want to merge {{.selectedBranch}} into {{.checkedOutBranch}}?",
FwdNoUpstream: "Cannot fast-forward a branch with no upstream", FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
FwdCommitsToPush: "Cannot fast-forward a branch with commits to push", FwdCommitsToPush: "Cannot fast-forward a branch with commits to push",
ErrorOccurred: "An error occurred! Please create an issue at https://github.com/jesseduffield/lazygit/issues", ErrorOccurred: "An error occurred! Please create an issue at",
NoRoom: "Not enough room", NoRoom: "Not enough room",
YouAreHere: "YOU ARE HERE", YouAreHere: "YOU ARE HERE",
LcRewordNotSupported: "rewording commits while interactively rebasing is not currently supported", LcRewordNotSupported: "rewording commits while interactively rebasing is not currently supported",
@ -1189,6 +1190,7 @@ func englishTranslationSet() TranslationSet {
ToggleShowCommandLog: "Toggle show/hide command log", ToggleShowCommandLog: "Toggle show/hide command log",
FocusCommandLog: "Focus command log", FocusCommandLog: "Focus command log",
CommandLogHeader: "You can hide/focus this panel by pressing '%s' or hide it permanently in your config with `gui.showCommandLog: false`\n", CommandLogHeader: "You can hide/focus this panel by pressing '%s' or hide it permanently in your config with `gui.showCommandLog: false`\n",
RandomTip: "Random Tip",
Spans: Spans{ Spans: Spans{
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
CheckoutCommit: "Checkout commit", CheckoutCommit: "Checkout commit",

View File

@ -145,7 +145,7 @@ func polishTranslationSet() TranslationSet {
ConfirmMerge: "Are you sure you want to merge {{.selectedBranch}} into {{.checkedOutBranch}}?", ConfirmMerge: "Are you sure you want to merge {{.selectedBranch}} into {{.checkedOutBranch}}?",
FwdNoUpstream: "Cannot fast-forward a branch with no upstream", FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
FwdCommitsToPush: "Cannot fast-forward a branch with commits to push", FwdCommitsToPush: "Cannot fast-forward a branch with commits to push",
ErrorOccurred: "An error occurred! Please create an issue at https://github.com/jesseduffield/lazygit/issues", ErrorOccurred: "An error occurred! Please create an issue at",
MainTitle: "Main", MainTitle: "Main",
NormalTitle: "Normal", NormalTitle: "Normal",
LcSoftReset: "soft reset", LcSoftReset: "soft reset",

View File

@ -17,6 +17,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -36,10 +37,6 @@ type Updaterer interface {
Update() Update()
} }
const (
PROJECT_URL = "https://github.com/jesseduffield/lazygit"
)
// NewUpdater creates a new updater // NewUpdater creates a new updater
func NewUpdater(log *logrus.Entry, config config.AppConfigurer, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet) (*Updater, error) { func NewUpdater(log *logrus.Entry, config config.AppConfigurer, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet) (*Updater, error) {
contextLogger := log.WithField("context", "updates") contextLogger := log.WithField("context", "updates")
@ -53,7 +50,7 @@ func NewUpdater(log *logrus.Entry, config config.AppConfigurer, osCommand *oscom
} }
func (u *Updater) getLatestVersionNumber() (string, error) { func (u *Updater) getLatestVersionNumber() (string, error) {
req, err := http.NewRequest("GET", PROJECT_URL+"/releases/latest", nil) req, err := http.NewRequest("GET", constants.Links.RepoUrl+"/releases/latest", nil)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -235,7 +232,7 @@ func (u *Updater) zipExtension() string {
func (u *Updater) getBinaryUrl(newVersion string) (string, error) { func (u *Updater) getBinaryUrl(newVersion string) (string, error) {
url := fmt.Sprintf( url := fmt.Sprintf(
"%s/releases/download/%s/lazygit_%s_%s_%s.%s", "%s/releases/download/%s/lazygit_%s_%s_%s.%s",
PROJECT_URL, constants.Links.RepoUrl,
newVersion, newVersion,
newVersion[1:], newVersion[1:],
u.mappedOs(runtime.GOOS), u.mappedOs(runtime.GOOS),