Compare commits

...
10 Commits
Author SHA1 Message Date
Dawid Dziurla d2ea5dd8b7 workflows: don't sign commit 2020-10-14 00:01:19 +02:00
Dawid Dziurla e0381b5920 workflows: run CD on Ubuntu 20.04
So we can get newer git-buildpackage
2020-10-13 23:51:40 +02:00
Dawid Dziurla dac3978983 Merge pull request #1049 from jesseduffield/cd-update-ppa
workflows: update PPA repo as part of CD process
2020-10-13 23:33:19 +02:00
Dawid Dziurla 7074cc28b8 Merge pull request #1050 from jesseduffield/dawidd6-patch-1
utils: ReplaceAll -> Replace
2020-10-13 17:28:33 +02:00
Dawid Dziurla 327b6ad097 utils: ReplaceAll -> Replace
Fix compatibility with older Go compiler versions
2020-10-13 17:25:37 +02:00
Dawid Dziurla 1dc837527f workflows: update PPA repo as part of CD process 2020-10-13 13:43:14 +02:00
Jesse Duffield b1dd3c4866 support rebinding confirm/newline keys in editor 2020-10-13 08:21:09 +11:00
Jesse Duffield 624fb8da21 preserve width of side panel when main view split unless window is wide enough 2020-10-13 07:31:14 +11:00
nullawhale 1ff405edd8 Copy a commit message to clipboard: Changes to latest version 2020-10-12 21:04:01 +11:00
Jesse Duffield 031e97ef91 more password checks on commands that talk to the remote 2020-10-12 19:07:40 +11:00
16 changed files with 152 additions and 72 deletions
+18 -1
View File
@@ -7,7 +7,7 @@ on:
jobs:
cd:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
@@ -26,3 +26,20 @@ jobs:
with:
token: ${{secrets.GITHUB_API_TOKEN}}
formula: lazygit
- name: Checkout PPA repo
uses: actions/checkout@v2
with:
repository: dawidd6/lazygit-debian
token: ${{secrets.GITHUB_API_TOKEN}}
fetch-depth: 0
- name: Update PPA repo
run: |
version="$(echo "$GITHUB_REF" | sed 's@refs/tags/v@@')"
sudo apt install -y git-buildpackage
git fetch --tags https://github.com/$GITHUB_REPOSITORY
gbp import-ref -u "$version"
gbp dch -D xenial -N "$version"-1
git add debian/changelog
git commit -m "d/changelog: dch $version"
gbp tag
git push --tags origin master
+3
View File
@@ -111,6 +111,8 @@ Default path for the config file:
diffingMenu: 'W'
diffingMenu-alt: '<c-e>' # deprecated
copyToClipboard: '<c-o>'
submitEditorText: '<enter>'
appendNewline: '<tab>'
status:
checkForUpdate: 'u'
recentRepos: '<enter>'
@@ -156,6 +158,7 @@ Default path for the config file:
tagCommit: 'T'
checkoutCommit: '<space>'
resetCherryPick: '<c-R>'
copyCommitMessageToClipboard: '<c-y>'
stash:
popStash: 'g'
commitFiles:
+7 -1
View File
@@ -22,7 +22,13 @@ func (c *GitCommand) ResetToCommit(sha string, strength string, options oscomman
// Commit commits to git
func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error) {
command := fmt.Sprintf("git commit %s -m %s", flags, strconv.Quote(message))
splitMessage := strings.Split(message, "\n")
lineArgs := ""
for _, line := range splitMessage {
lineArgs += fmt.Sprintf(" -m %s", strconv.Quote(line))
}
command := fmt.Sprintf("git commit %s%s", flags, lineArgs)
if c.usingGpg() {
return c.OSCommand.ShellCommandFromString(command), nil
}
+5 -2
View File
@@ -1,6 +1,8 @@
package commands
import (
"fmt"
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
@@ -20,8 +22,9 @@ func (c *GitCommand) UpdateRemoteUrl(remoteName string, updatedUrl string) error
return c.OSCommand.RunCommand("git remote set-url %s %s", remoteName, updatedUrl)
}
func (c *GitCommand) DeleteRemoteBranch(remoteName string, branchName string) error {
return c.OSCommand.RunCommand("git push %s --delete %s", remoteName, branchName)
func (c *GitCommand) DeleteRemoteBranch(remoteName string, branchName string, promptUserForCredential func(string) string) error {
command := fmt.Sprintf("git push %s --delete %s", remoteName, branchName)
return c.OSCommand.DetectUnamePass(command, promptUserForCredential)
}
// CheckRemoteBranchExists Returns remote branch
+5 -2
View File
@@ -1,5 +1,7 @@
package commands
import "fmt"
func (c *GitCommand) CreateLightweightTag(tagName string, commitSha string) error {
return c.OSCommand.RunCommand("git tag %s %s", tagName, commitSha)
}
@@ -8,6 +10,7 @@ func (c *GitCommand) DeleteTag(tagName string) error {
return c.OSCommand.RunCommand("git tag -d %s", tagName)
}
func (c *GitCommand) PushTag(remoteName string, tagName string) error {
return c.OSCommand.RunCommand("git push %s %s", remoteName, tagName)
func (c *GitCommand) PushTag(remoteName string, tagName string, promptUserForCredential func(string) string) error {
command := fmt.Sprintf("git push %s %s", remoteName, tagName)
return c.OSCommand.DetectUnamePass(command, promptUserForCredential)
}
+43 -36
View File
@@ -144,6 +144,8 @@ type KeybindingUniversalConfig struct {
DiffingMenu string `yaml:"diffingMenu"`
DiffingMenuAlt string `yaml:"diffingMenu-alt"`
CopyToClipboard string `yaml:"copyToClipboard"`
SubmitEditorText string `yaml:"submitEditorText"`
AppendNewline string `yaml:"appendNewline"`
}
type KeybindingStatusConfig struct {
@@ -180,24 +182,25 @@ type KeybindingBranchesConfig struct {
}
type KeybindingCommitsConfig struct {
SquashDown string `yaml:"squashDown"`
RenameCommit string `yaml:"renameCommit"`
RenameCommitWithEditor string `yaml:"renameCommitWithEditor"`
ViewResetOptions string `yaml:"viewResetOptions"`
MarkCommitAsFixup string `yaml:"markCommitAsFixup"`
CreateFixupCommit string `yaml:"createFixupCommit"`
SquashAboveCommits string `yaml:"squashAboveCommits"`
MoveDownCommit string `yaml:"moveDownCommit"`
MoveUpCommit string `yaml:"moveUpCommit"`
AmendToCommit string `yaml:"amendToCommit"`
PickCommit string `yaml:"pickCommit"`
RevertCommit string `yaml:"revertCommit"`
CherryPickCopy string `yaml:"cherryPickCopy"`
CherryPickCopyRange string `yaml:"cherryPickCopyRange"`
PasteCommits string `yaml:"pasteCommits"`
TagCommit string `yaml:"tagCommit"`
CheckoutCommit string `yaml:"checkoutCommit"`
ResetCherryPick string `yaml:"resetCherryPick"`
SquashDown string `yaml:"squashDown"`
RenameCommit string `yaml:"renameCommit"`
RenameCommitWithEditor string `yaml:"renameCommitWithEditor"`
ViewResetOptions string `yaml:"viewResetOptions"`
MarkCommitAsFixup string `yaml:"markCommitAsFixup"`
CreateFixupCommit string `yaml:"createFixupCommit"`
SquashAboveCommits string `yaml:"squashAboveCommits"`
MoveDownCommit string `yaml:"moveDownCommit"`
MoveUpCommit string `yaml:"moveUpCommit"`
AmendToCommit string `yaml:"amendToCommit"`
PickCommit string `yaml:"pickCommit"`
RevertCommit string `yaml:"revertCommit"`
CherryPickCopy string `yaml:"cherryPickCopy"`
CherryPickCopyRange string `yaml:"cherryPickCopyRange"`
PasteCommits string `yaml:"pasteCommits"`
TagCommit string `yaml:"tagCommit"`
CheckoutCommit string `yaml:"checkoutCommit"`
ResetCherryPick string `yaml:"resetCherryPick"`
CopyCommitMessageToClipboard string `yaml:"copyCommitMessageToClipboard"`
}
type KeybindingStashConfig struct {
@@ -359,6 +362,8 @@ func GetDefaultConfig() *UserConfig {
DiffingMenu: "W",
DiffingMenuAlt: "<c-e>",
CopyToClipboard: "<c-o>",
SubmitEditorText: "<enter>",
AppendNewline: "<tab>",
},
Status: KeybindingStatusConfig{
CheckForUpdate: "u",
@@ -390,24 +395,26 @@ func GetDefaultConfig() *UserConfig {
SetUpstream: "u",
FetchRemote: "f",
},
Commits: KeybindingCommitsConfig{SquashDown: "s",
RenameCommit: "r",
RenameCommitWithEditor: "R",
ViewResetOptions: "g",
MarkCommitAsFixup: "f",
CreateFixupCommit: "F",
SquashAboveCommits: "S",
MoveDownCommit: "<c-j>",
MoveUpCommit: "<c-k>",
AmendToCommit: "A",
PickCommit: "p",
RevertCommit: "t",
CherryPickCopy: "c",
CherryPickCopyRange: "C",
PasteCommits: "v",
TagCommit: "T",
CheckoutCommit: "<space>",
ResetCherryPick: "<c-R>",
Commits: KeybindingCommitsConfig{
SquashDown: "s",
RenameCommit: "r",
RenameCommitWithEditor: "R",
ViewResetOptions: "g",
MarkCommitAsFixup: "f",
CreateFixupCommit: "F",
SquashAboveCommits: "S",
MoveDownCommit: "<c-j>",
MoveUpCommit: "<c-k>",
AmendToCommit: "A",
PickCommit: "p",
RevertCommit: "t",
CherryPickCopy: "c",
CherryPickCopyRange: "C",
PasteCommits: "v",
TagCommit: "T",
CheckoutCommit: "<space>",
ResetCherryPick: "<c-R>",
CopyCommitMessageToClipboard: "<c-y>",
},
Stash: KeybindingStashConfig{
PopStash: "g",
+29 -18
View File
@@ -47,7 +47,7 @@ func (gui *Gui) getMidSectionWeights() (int, int) {
mainSectionWeight := int(1/sidePanelWidthRatio) - 1
sideSectionWeight := 1
if gui.isMainPanelSplit() {
if gui.splitMainPanelSideBySide() {
mainSectionWeight = 5 // need to shrink side panel to make way for main panels if side-by-side
}
@@ -108,6 +108,28 @@ func (gui *Gui) infoSectionChildren(informationStr string, appStatus string) []*
return result
}
func (gui *Gui) splitMainPanelSideBySide() bool {
if !gui.isMainPanelSplit() {
return false
}
mainPanelSplitMode := gui.Config.GetUserConfig().Gui.MainPanelSplitMode
width, height := gui.g.Size()
switch mainPanelSplitMode {
case "vertical":
return false
case "horizontal":
return true
default:
if width < 200 && height > 30 { // 2 80 character width panels + 40 width for side panel
return false
} else {
return true
}
}
}
func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions {
width, height := gui.g.Size()
@@ -119,6 +141,11 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map
sidePanelsDirection = boxlayout.ROW
}
mainPanelsDirection := boxlayout.ROW
if gui.splitMainPanelSideBySide() {
mainPanelsDirection = boxlayout.COLUMN
}
root := &boxlayout.Box{
Direction: boxlayout.ROW,
Children: []*boxlayout.Box{
@@ -132,23 +159,7 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map
ConditionalChildren: gui.sidePanelChildren,
},
{
ConditionalDirection: func(width int, height int) int {
mainPanelSplitMode := gui.Config.GetUserConfig().Gui.MainPanelSplitMode
switch mainPanelSplitMode {
case "vertical":
return boxlayout.ROW
case "horizontal":
return boxlayout.COLUMN
default:
if width < 160 && height > 30 { // 2 80 character width panels
return boxlayout.ROW
} else {
return boxlayout.COLUMN
}
}
},
Direction: boxlayout.COLUMN,
Direction: mainPanelsDirection,
Weight: mainSectionWeight,
Children: gui.mainSectionChildren(),
},
+6 -1
View File
@@ -83,6 +83,11 @@ func (gui *Gui) RenderCommitLength() {
// we've just copy+pasted the editor from gocui to here so that we can also re-
// render the commit message length on each keypress
func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
newlineKey, ok := gui.getKey(gui.Config.GetUserConfig().Keybinding.Universal.AppendNewline).(gocui.Key)
if !ok {
newlineKey = gocui.KeyTab
}
switch {
case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
v.EditDelete(true)
@@ -96,7 +101,7 @@ func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod g
v.MoveCursor(-1, 0, false)
case key == gocui.KeyArrowRight:
v.MoveCursor(1, 0, false)
case key == gocui.KeyTab:
case key == newlineKey:
v.EditNewLine()
case key == gocui.KeySpace:
v.EditWrite(' ')
+13
View File
@@ -591,3 +591,16 @@ func (gui *Gui) handleGotoBottomForCommitsPanel(g *gocui.Gui, v *gocui.View) err
return nil
}
func (gui *Gui) handleCopySelectedCommitMessageToClipboard() error {
commit := gui.getSelectedLocalCommit()
if commit == nil {
return nil
}
message, err := gui.GitCommand.GetCommitMessage(commit.Sha)
if err != nil {
return gui.surfaceError(err)
}
return gui.OSCommand.CopyToClipboard(message)
}
+8 -1
View File
@@ -821,6 +821,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.wrappedHandler(gui.exitCherryPickingMode),
Description: gui.Tr.LcResetCherryPick,
},
{
ViewName: "commits",
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey(config.Commits.CopyCommitMessageToClipboard),
Handler: gui.wrappedHandler(gui.handleCopySelectedCommitMessageToClipboard),
Description: gui.Tr.LcCopyCommitMessageToClipboard,
},
{
ViewName: "commits",
Contexts: []string{REFLOG_COMMITS_CONTEXT_KEY},
@@ -964,7 +971,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "commitMessage",
Key: gui.getKey(config.Universal.Confirm),
Key: gui.getKey(config.Universal.SubmitEditorText),
Modifier: gocui.ModNone,
Handler: gui.handleCommitConfirm,
},
+2 -3
View File
@@ -60,9 +60,8 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error {
prompt: message,
handleConfirm: func() error {
return gui.WithWaitingStatus(gui.Tr.DeletingStatus, func() error {
if err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name); err != nil {
return err
}
err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name, gui.promptUserForCredential)
gui.handleCredentialsPopup(err)
return gui.refreshSidePanels(refreshOptions{scope: []int{BRANCHES, REMOTES}})
})
-1
View File
@@ -166,7 +166,6 @@ func (gui *Gui) handleFetchRemote(g *gocui.Gui, v *gocui.View) error {
gui.Mutexes.FetchMutex.Lock()
defer gui.Mutexes.FetchMutex.Unlock()
// TODO: test this
err := gui.GitCommand.FetchRemote(remote.Name, gui.promptUserForCredential)
gui.handleCredentialsPopup(err)
+6 -4
View File
@@ -98,10 +98,12 @@ func (gui *Gui) handlePushTag(g *gocui.Gui, v *gocui.View) error {
)
return gui.prompt(title, "origin", func(response string) error {
if err := gui.GitCommand.PushTag(response, tag.Name); err != nil {
return gui.surfaceError(err)
}
return nil
return gui.WithWaitingStatus(gui.Tr.PushingTagStatus, func() error {
err := gui.GitCommand.PushTag(response, tag.Name, gui.promptUserForCredential)
gui.handleCredentialsPopup(err)
return nil
})
})
}
+1
View File
@@ -371,6 +371,7 @@ func dutchTranslationSet() TranslationSet {
LcOpenDiffingMenu: "open diff menu",
LcShowingGitDiff: "laat output zien voor:",
LcCopyCommitShaToClipboard: "copieer commit SHA naar clipboard",
LcCopyCommitMessageToClipboard: "copieer commit bericht naar clipboard",
LcCopyBranchNameToClipboard: "copieer branch name naar clipboard",
LcCopyFileNameToClipboard: "kopieer de bestandsnaam naar het klembord",
LcCopyCommitFileNameToClipboard: "kopieer de vastgelegde bestandsnaam naar het klembord",
+4
View File
@@ -381,6 +381,7 @@ type TranslationSet struct {
LcOpenDiffingMenu string
LcShowingGitDiff string
LcCopyCommitShaToClipboard string
LcCopyCommitMessageToClipboard string
LcCopyBranchNameToClipboard string
LcCopyFileNameToClipboard string
LcCopyCommitFileNameToClipboard string
@@ -427,6 +428,7 @@ type TranslationSet struct {
SubCommitsTitle string
SubmodulesTitle string
NavigationTitle string
PushingTagStatus string
}
const englishReleaseNotes = `## lazygit 0.23.2 Release Notes
@@ -878,6 +880,7 @@ func englishTranslationSet() TranslationSet {
LcOpenDiffingMenu: "open diff menu",
LcShowingGitDiff: "showing output for:",
LcCopyCommitShaToClipboard: "copy commit SHA to clipboard",
LcCopyCommitMessageToClipboard: "copy commit message to clipboard",
LcCopyBranchNameToClipboard: "copy branch name to clipboard",
LcCopyFileNameToClipboard: "copy the file name to the clipboard",
LcCopyCommitFileNameToClipboard: "copy the committed file name to the clipboard",
@@ -924,5 +927,6 @@ func englishTranslationSet() TranslationSet {
SubCommitsTitle: "Sub-commits",
SubmodulesTitle: "Submodules",
NavigationTitle: "List Panel Navigation",
PushingTagStatus: "pushing tag",
}
}
+2 -2
View File
@@ -102,8 +102,8 @@ func Loader() string {
// ResolvePlaceholderString populates a template with values
func ResolvePlaceholderString(str string, arguments map[string]string) string {
for key, value := range arguments {
str = strings.ReplaceAll(str, "{{"+key+"}}", value)
str = strings.ReplaceAll(str, "{{."+key+"}}", value)
str = strings.Replace(str, "{{"+key+"}}", value, -1)
str = strings.Replace(str, "{{."+key+"}}", value, -1)
}
return str
}