Skip to content

Commit

Permalink
Move autosync code to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
vHanda committed May 5, 2022
1 parent c82c3d3 commit 6138071
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
38 changes: 38 additions & 0 deletions autosync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import "github.com/ztrue/tracerr"

func autoSync(repoPath string) error {
var err error
err = ensureGitAuthor(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = commit(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = fetch(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = rebase(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = push(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

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

return nil
}
35 changes: 0 additions & 35 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,38 +124,3 @@ func watchForChanges(ctx *cli.Context) error {
// func poll() {
// fmt.Println("Poll")
// }

func autoSync(repoPath string) error {
var err error
err = ensureGitAuthor(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = commit(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = fetch(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = rebase(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

err = push(repoPath)
if err != nil {
return tracerr.Wrap(err)
}

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

return nil
}

0 comments on commit 6138071

Please sign in to comment.