Skip to content

Commit

Permalink
Send a notification if a rebase fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vHanda committed May 5, 2022
1 parent b1de9d0 commit 7a2177c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
14 changes: 12 additions & 2 deletions common/autosync.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package common

import (
"errors"

"github.com/gen2brain/beeep"
"github.com/ztrue/tracerr"
)

Expand All @@ -23,6 +26,15 @@ func AutoSync(repoPath string) error {

err = rebase(repoPath)
if err != nil {
if errors.Is(err, errRebaseFailed) {
err := beeep.Alert("Git Auto Sync - Conflict", "Could not rebase for - "+repoPath, "assets/warning.png")
if err != nil {
return tracerr.Wrap(err)
}
}
// How should we continue?
// - Keep sending the notification each time?
// - Or something a bit better?
return tracerr.Wrap(err)
}

Expand All @@ -31,8 +43,6 @@ func AutoSync(repoPath string) error {
return tracerr.Wrap(err)
}

// -> rebase if possible
// -> revert if rebase fails
// -> do a merge
// -> push the changes

Expand Down
15 changes: 1 addition & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"log"
"os"

"github.com/gen2brain/beeep"
cli "github.com/urfave/cli/v2"
"github.com/ztrue/tracerr"

Expand All @@ -14,7 +13,7 @@ import (
func main() {
app := &cli.App{
Name: "git-auto-sync",
Usage: "fight the loneliness!",
Usage: "Automatically Sync any Git Repo",
Commands: []*cli.Command{
{
Name: "watch",
Expand Down Expand Up @@ -45,18 +44,6 @@ func main() {
return nil
},
},
{
Name: "notify",
Usage: "Sync a repo right now",
Action: func(ctx *cli.Context) error {
err := beeep.Alert("Title", "Message body", "assets/warning.png")
if err != nil {
panic(err)
}

return nil
},
},
{
Name: "daemon",
Usage: "Interact with the background daemon",
Expand Down
1 change: 1 addition & 0 deletions todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Commands -

* Daemon + enable / disable
* Handle rebase / merge / merge-conflict (commit everything, pick newest, notify)
* Daemon - proper logs

0 comments on commit 7a2177c

Please sign in to comment.