Skip to content

Commit

Permalink
fix: svc rename
Browse files Browse the repository at this point in the history
  • Loading branch information
seriouspoop committed Nov 30, 2024
1 parent 17a8b89 commit b02afc5
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 32 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/manifoldco/promptui v0.9.0
github.com/pelletier/go-toml/v2 v2.2.3
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
)

require (
Expand All @@ -18,6 +19,7 @@ require (
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.5.0 // indirect
github.com/cyphar/filepath-securejoin v0.3.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
Expand All @@ -28,6 +30,7 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -36,4 +39,5 @@ require (
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 1 addition & 1 deletion svc/config.go → gogresSvc/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svc
package gogresSvc

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion svc/errors.go → gogresSvc/errors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svc
package gogresSvc

import "errors"

Expand Down
3 changes: 1 addition & 2 deletions svc/facade.go → gogresSvc/facade.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svc
package gogresSvc

import (
"os"
Expand Down Expand Up @@ -32,6 +32,5 @@ type scriptHelper interface {
CreateDir(path, name string) error
GenerateSSHKey(path, keyName, mail, passphrase string) error

// TODO -> replace this with go-git merge
PullMerge() (string, error)
}
2 changes: 1 addition & 1 deletion svc/repo.go → gogresSvc/repo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svc
package gogresSvc

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion svc/svc.go → gogresSvc/svc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svc
package gogresSvc

import (
"github.com/seriouspoop/gopush/config"
Expand Down
2 changes: 1 addition & 1 deletion svc/tests.go → gogresSvc/tests.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svc
package gogresSvc

import (
"github.com/seriouspoop/gopush/utils"
Expand Down
10 changes: 5 additions & 5 deletions internal/handler/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/MakeNowJust/heredoc/v2"
"github.com/seriouspoop/gopush/svc"
"github.com/seriouspoop/gopush/gogresSvc"
"github.com/seriouspoop/gopush/utils"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -38,7 +38,7 @@ func Init(s servicer) *cobra.Command {

err = s.LoadProject()
if err != nil {
if errors.Is(err, svc.ErrRepoNotFound) {
if errors.Is(err, gogresSvc.ErrRepoNotFound) {
err := s.InitializeRepo()
if err != nil {
return err
Expand All @@ -61,10 +61,10 @@ func Init(s servicer) *cobra.Command {
// TODO -> seperate control flow for http and ssh
err = s.SetRemoteHTTPAuth()
if err != nil {
if errors.Is(err, svc.ErrInvalidAuthMethod) {
if errors.Is(err, gogresSvc.ErrInvalidAuthMethod) {
err := s.SetRemoteSSHAuth()
if err != nil {
if errors.Is(err, svc.ErrWaitExit) {
if errors.Is(err, gogresSvc.ErrWaitExit) {
return nil
}
return err
Expand All @@ -90,7 +90,7 @@ func Init(s servicer) *cobra.Command {
utils.Logger(utils.LOG_INFO, "Pulling commits from main...")
err = s.Pull(true)
if err != nil {
if errors.Is(err, svc.ErrPullFailed) {
if errors.Is(err, gogresSvc.ErrPullFailed) {
utils.Logger(utils.LOG_INFO, "Remote pull failed, try pulling manually.")
}
return err
Expand Down
8 changes: 4 additions & 4 deletions internal/handler/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

"github.com/MakeNowJust/heredoc/v2"
"github.com/seriouspoop/gopush/gogresSvc"
"github.com/seriouspoop/gopush/model"
"github.com/seriouspoop/gopush/svc"
"github.com/seriouspoop/gopush/utils"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -51,7 +51,7 @@ func Run(s servicer) *cobra.Command {
// Load config
err = s.LoadConfig()
if err != nil {
if errors.Is(err, svc.ErrFileNotFound) {
if errors.Is(err, gogresSvc.ErrFileNotFound) {
fmt.Println(heredoc.Doc(`
Config file not found.
Use "gopush init" to generate your config file.
Expand Down Expand Up @@ -101,7 +101,7 @@ func Run(s servicer) *cobra.Command {
utils.Logger(utils.LOG_INFO, "Pulling remote changes...")
err = s.Pull(false)
if err != nil {
if errors.Is(err, svc.ErrAuthNotFound) {
if errors.Is(err, gogresSvc.ErrAuthNotFound) {
fmt.Println(heredoc.Doc(`
Auth credentials for current remote not found.
Use "gopush init" to generate your config file.
Expand All @@ -114,7 +114,7 @@ func Run(s servicer) *cobra.Command {
utils.Logger(utils.LOG_INFO, "Pushing changes...")
err = s.Push(setUpstreamBranch)
if err != nil {
if errors.Is(err, svc.ErrAuthNotFound) {
if errors.Is(err, gogresSvc.ErrAuthNotFound) {
fmt.Println(heredoc.Doc(`
Auth credentials for current remote are missing.
Run "gopush init" to setup auth credentials.
Expand Down
32 changes: 16 additions & 16 deletions internal/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@ package internal

import (
"github.com/MakeNowJust/heredoc/v2"
"github.com/seriouspoop/gopush/gogresSvc"
"github.com/seriouspoop/gopush/internal/handler"
"github.com/seriouspoop/gopush/repo/git"
"github.com/seriouspoop/gopush/repo/script"
"github.com/seriouspoop/gopush/svc"
"github.com/spf13/cobra"
)

type Root struct {
git *git.Git
bash *script.Bash
s *svc.Svc
s *gogresSvc.Svc
}

func NewRoot() (*Root, error) {
gitHelper, err := git.New(&git.Errors{
RemoteNotFound: svc.ErrRemoteNotFound,
RemoteNotLoaded: svc.ErrRemoteNotLoaded,
RemoteAlreadyExists: svc.ErrRemoteAlreadyExists,
RepoAlreadyExists: svc.ErrRepoAlreadyExists,
RepoNotFound: svc.ErrRepoNotFound,
PullFailed: svc.ErrPullFailed,
AuthNotFound: svc.ErrAuthNotFound,
InvalidAuthMethod: svc.ErrInvalidAuthMethod,
InvalidPassphrase: svc.ErrInvalidPassphrase,
KeyNotSupported: svc.ErrKeyNotSupported,
AlreadyUpToDate: svc.ErrAlreadyUpToDate,
RemoteBranchNotFound: svc.ErrRemoteBranchNotFound,
RemoteNotFound: gogresSvc.ErrRemoteNotFound,
RemoteNotLoaded: gogresSvc.ErrRemoteNotLoaded,
RemoteAlreadyExists: gogresSvc.ErrRemoteAlreadyExists,
RepoAlreadyExists: gogresSvc.ErrRepoAlreadyExists,
RepoNotFound: gogresSvc.ErrRepoNotFound,
PullFailed: gogresSvc.ErrPullFailed,
AuthNotFound: gogresSvc.ErrAuthNotFound,
InvalidAuthMethod: gogresSvc.ErrInvalidAuthMethod,
InvalidPassphrase: gogresSvc.ErrInvalidPassphrase,
KeyNotSupported: gogresSvc.ErrKeyNotSupported,
AlreadyUpToDate: gogresSvc.ErrAlreadyUpToDate,
RemoteBranchNotFound: gogresSvc.ErrRemoteBranchNotFound,
})
if err != nil {
return nil, err
}

bashHelper := script.New(&script.Error{
FileNotExists: svc.ErrFileNotFound,
FileNotExists: gogresSvc.ErrFileNotFound,
})

s := svc.New(gitHelper, bashHelper)
s := gogresSvc.New(gitHelper, bashHelper)

return &Root{
git: gitHelper,
Expand Down

0 comments on commit b02afc5

Please sign in to comment.