mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
add some shameless self promotion
This commit is contained in:
parent
98666186ee
commit
de5bcb8b9c
@ -37,7 +37,7 @@ type AppConfigurer interface {
|
|||||||
GetUserConfig() *viper.Viper
|
GetUserConfig() *viper.Viper
|
||||||
GetUserConfigDir() string
|
GetUserConfigDir() string
|
||||||
GetAppState() *AppState
|
GetAppState() *AppState
|
||||||
WriteToUserConfig(string, string) error
|
WriteToUserConfig(string, interface{}) error
|
||||||
SaveAppState() error
|
SaveAppState() error
|
||||||
LoadAppState() error
|
LoadAppState() error
|
||||||
SetIsNewRepo(bool)
|
SetIsNewRepo(bool)
|
||||||
@ -192,7 +192,7 @@ func LoadAndMergeFile(v *viper.Viper, filename string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WriteToUserConfig adds a key/value pair to the user's config and saves it
|
// WriteToUserConfig adds a key/value pair to the user's config and saves it
|
||||||
func (c *AppConfig) WriteToUserConfig(key, value string) error {
|
func (c *AppConfig) WriteToUserConfig(key string, value interface{}) error {
|
||||||
// reloading the user config directly (without defaults) so that we're not
|
// reloading the user config directly (without defaults) so that we're not
|
||||||
// writing any defaults back to the user's config
|
// writing any defaults back to the user's config
|
||||||
v, _, err := LoadConfig("config", false)
|
v, _, err := LoadConfig("config", false)
|
||||||
@ -263,6 +263,7 @@ update:
|
|||||||
method: prompt # can be: prompt | background | never
|
method: prompt # can be: prompt | background | never
|
||||||
days: 14 # how often a update is checked for
|
days: 14 # how often a update is checked for
|
||||||
reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined'
|
reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined'
|
||||||
|
splashUpdatesIndex: 0
|
||||||
confirmOnQuit: false
|
confirmOnQuit: false
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
|
|||||||
|
|
||||||
func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt string) (int, int, int, int) {
|
func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt string) (int, int, int, int) {
|
||||||
width, height := g.Size()
|
width, height := g.Size()
|
||||||
panelWidth := width / 2
|
panelWidth := 4 * width / 7
|
||||||
panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
|
panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
|
||||||
return width/2 - panelWidth/2,
|
return width/2 - panelWidth/2,
|
||||||
height/2 - panelHeight/2 - panelHeight%2 - 1,
|
height/2 - panelHeight/2 - panelHeight%2 - 1,
|
||||||
|
@ -30,6 +30,8 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const StartupPopupVersion = 1
|
||||||
|
|
||||||
// OverlappingEdges determines if panel edges overlap
|
// OverlappingEdges determines if panel edges overlap
|
||||||
var OverlappingEdges = false
|
var OverlappingEdges = false
|
||||||
|
|
||||||
@ -618,20 +620,42 @@ func (gui *Gui) loadNewRepo() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if gui.Config.GetUserConfig().GetString("reporting") == "undetermined" {
|
|
||||||
if err := gui.promptAnonymousReporting(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) promptAnonymousReporting() error {
|
func (gui *Gui) showInitialPopups(tasks []func(chan struct{}) error) {
|
||||||
|
gui.waitForIntro.Add(len(tasks))
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for _, task := range tasks {
|
||||||
|
go func() {
|
||||||
|
if err := task(done); err != nil {
|
||||||
|
_ = gui.createErrorPanel(gui.g, err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-done
|
||||||
|
gui.waitForIntro.Done()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) showShamelessSelfPromotionMessage(done chan struct{}) error {
|
||||||
|
onConfirm := func(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
done <- struct{}{}
|
||||||
|
return gui.Config.WriteToUserConfig("startupPopupVersion", StartupPopupVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
return gui.createConfirmationPanel(gui.g, nil, true, gui.Tr.SLocalize("ShamelessSelfPromotionTitle"), gui.Tr.SLocalize("ShamelessSelfPromotionMessage"), onConfirm, onConfirm)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) promptAnonymousReporting(done chan struct{}) error {
|
||||||
return gui.createConfirmationPanel(gui.g, nil, true, gui.Tr.SLocalize("AnonymousReportingTitle"), gui.Tr.SLocalize("AnonymousReportingPrompt"), func(g *gocui.Gui, v *gocui.View) error {
|
return gui.createConfirmationPanel(gui.g, nil, true, gui.Tr.SLocalize("AnonymousReportingTitle"), gui.Tr.SLocalize("AnonymousReportingPrompt"), func(g *gocui.Gui, v *gocui.View) error {
|
||||||
gui.waitForIntro.Done()
|
done <- struct{}{}
|
||||||
return gui.Config.WriteToUserConfig("reporting", "on")
|
return gui.Config.WriteToUserConfig("reporting", "on")
|
||||||
}, func(g *gocui.Gui, v *gocui.View) error {
|
}, func(g *gocui.Gui, v *gocui.View) error {
|
||||||
gui.waitForIntro.Done()
|
done <- struct{}{}
|
||||||
return gui.Config.WriteToUserConfig("reporting", "off")
|
return gui.Config.WriteToUserConfig("reporting", "off")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -717,15 +741,22 @@ func (gui *Gui) Run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popupTasks := []func(chan struct{}) error{}
|
||||||
if gui.Config.GetUserConfig().GetString("reporting") == "undetermined" {
|
if gui.Config.GetUserConfig().GetString("reporting") == "undetermined" {
|
||||||
gui.waitForIntro.Add(2)
|
popupTasks = append(popupTasks, gui.promptAnonymousReporting)
|
||||||
} else {
|
|
||||||
gui.waitForIntro.Add(1)
|
|
||||||
}
|
}
|
||||||
|
configPopupVersion := gui.Config.GetUserConfig().GetInt("StartupPopupVersion")
|
||||||
|
// -1 means we've disabled these popups
|
||||||
|
if configPopupVersion != -1 && configPopupVersion < StartupPopupVersion {
|
||||||
|
popupTasks = append(popupTasks, gui.showShamelessSelfPromotionMessage)
|
||||||
|
}
|
||||||
|
gui.showInitialPopups(popupTasks)
|
||||||
|
|
||||||
|
gui.waitForIntro.Add(1)
|
||||||
if gui.Config.GetUserConfig().GetBool("git.autoFetch") {
|
if gui.Config.GetUserConfig().GetBool("git.autoFetch") {
|
||||||
go gui.startBackgroundFetch()
|
go gui.startBackgroundFetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.goEvery(time.Second*10, gui.refreshFiles)
|
gui.goEvery(time.Second*10, gui.refreshFiles)
|
||||||
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
|
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
|
||||||
|
|
||||||
@ -735,6 +766,8 @@ func (gui *Gui) Run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui.Log.Warn("starting main loop")
|
||||||
|
|
||||||
err = g.MainLoop()
|
err = g.MainLoop()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -806,7 +839,7 @@ func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if cx > len(gui.Tr.SLocalize("Donate")) {
|
if cx > len(gui.Tr.SLocalize("Donate")) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return gui.OSCommand.OpenLink("https://donorbox.org/lazygit")
|
return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield")
|
||||||
}
|
}
|
||||||
|
|
||||||
// setColorScheme sets the color scheme for the app based on the user config
|
// setColorScheme sets the color scheme for the app based on the user config
|
||||||
|
@ -438,6 +438,19 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "AnonymousReportingPrompt",
|
ID: "AnonymousReportingPrompt",
|
||||||
Other: "Would you like to enable anonymous reporting data to help improve lazygit? (enter/esc)",
|
Other: "Would you like to enable anonymous reporting data to help improve lazygit? (enter/esc)",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "ShamelessSelfPromotionTitle",
|
||||||
|
Other: "Shameless Self Promotion",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "ShamelessSelfPromotionMessage",
|
||||||
|
Other: `Thanks for using lazygit! Three things to share with you:
|
||||||
|
|
||||||
|
1) lazygit now has basic mouse support!
|
||||||
|
|
||||||
|
2) If you want to learn about lazygit's features, watch this vid:
|
||||||
|
https://youtu.be/CPLdltN7wgE
|
||||||
|
|
||||||
|
3) Github are now matching any donations dollar-for-dollar for the next 12 months, so if you've been tossing up over whether to click the donate link in the bottom right corner, now is the time!`,
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "GitconfigParseErr",
|
ID: "GitconfigParseErr",
|
||||||
Other: `Gogit failed to parse your gitconfig file due to the presence of unquoted '\' characters. Removing these should fix the issue.`,
|
Other: `Gogit failed to parse your gitconfig file due to the presence of unquoted '\' characters. Removing these should fix the issue.`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user