summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>2018-12-04 00:47:30 +0300
committerIbrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>2018-12-04 00:47:30 +0300
commit9e5b1546305a8ac245a1b2cfe14446c0797308ac (patch)
treec787a7c8dd4514f8f1da9564e15f7df90b396616
parentadded initial logging to git package (diff)
downloadgitbatch-9e5b1546305a8ac245a1b2cfe14446c0797308ac.tar.gz
reverse scrolling on commits implemented
-rw-r--r--README.md2
-rw-r--r--pkg/git/commit.go16
-rw-r--r--pkg/gui/commitsview.go13
-rw-r--r--pkg/gui/keybindings.go8
4 files changed, 38 insertions, 1 deletions
diff --git a/README.md b/README.md
index 45d6e51..ba70ce8 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ run the `gitbatch` command from the parent of your git repositories. For start-u
- add testing
- select all feature
- arrange repositories to an order e.g. alphabetic, last modified, etc.
-- shift keys, i.e. **s** for iterate **shift + s** for reverse iteration
+- shift keys, i.e. **s** for iterate **alt + s** for reverse iteration (partially implemented)
- recursive repository search from the filesystem
- full src-d/go-git integration (*having some performance issues*)
- implement config file to pre-define repo locations or some settings
diff --git a/pkg/git/commit.go b/pkg/git/commit.go
index f51801d..a15b3a4 100644
--- a/pkg/git/commit.go
+++ b/pkg/git/commit.go
@@ -47,6 +47,22 @@ func (entity *RepoEntity) NextCommit() error {
return nil
}
+// PreviousCommit iterates to opposite direction
+func (entity *RepoEntity) PreviousCommit() error {
+ currentCommitIndex := 0
+ for i, cs := range entity.Commits {
+ if cs.Hash == entity.Commit.Hash {
+ currentCommitIndex = i
+ }
+ }
+ if currentCommitIndex == 0 {
+ entity.Commit = entity.Commits[len(entity.Commits)-1]
+ return nil
+ }
+ entity.Commit = entity.Commits[currentCommitIndex-1]
+ return nil
+}
+
// loads the local commits by simply using git log way. ALso, gets the upstream
// diff commits
func (entity *RepoEntity) loadCommits() error {
diff --git a/pkg/gui/commitsview.go b/pkg/gui/commitsview.go
index 27abc69..91cb795 100644
--- a/pkg/gui/commitsview.go
+++ b/pkg/gui/commitsview.go
@@ -50,3 +50,16 @@ func (gui *Gui) nextCommit(g *gocui.Gui, v *gocui.View) error {
}
return err
}
+
+// reverse iteration handler for the commitsview
+func (gui *Gui) prevCommit(g *gocui.Gui, v *gocui.View) error {
+ var err error
+ entity := gui.getSelectedRepository()
+ if err = entity.PreviousCommit(); err != nil {
+ return err
+ }
+ if err = gui.updateCommits(g, entity); err != nil {
+ return err
+ }
+ return err
+}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index df3e4d8..f224bc3 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -109,6 +109,14 @@ func (gui *Gui) generateKeybindings() error {
Display: "s",
Description: "Iterate over commits",
Vital: false,
+ },{
+ View: mainViewFeature.Name,
+ Key: 's',
+ Modifier: gocui.ModAlt,
+ Handler: gui.prevCommit,
+ Display: "alt + s",
+ Description: "Iterate over commits",
+ Vital: false,
}, {
View: mainViewFeature.Name,
Key: 'd',