Fix import naming
This commit is contained in:
parent
14dcb9a66e
commit
d7615a90ba
@ -3,8 +3,8 @@ package grm
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
commands2 "gitlab.com/revalus/grm/internal/commands"
|
"gitlab.com/revalus/grm/internal/commands"
|
||||||
config2 "gitlab.com/revalus/grm/internal/config"
|
"gitlab.com/revalus/grm/internal/config"
|
||||||
"gitlab.com/revalus/grm/internal/echo"
|
"gitlab.com/revalus/grm/internal/echo"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
@ -13,18 +13,18 @@ import (
|
|||||||
const (
|
const (
|
||||||
AppName = "Git repository manager"
|
AppName = "Git repository manager"
|
||||||
AppDescription = "Manage your repository with simple grm"
|
AppDescription = "Manage your repository with simple grm"
|
||||||
VERSION = "0.3.0"
|
VERSION = "0.3.2"
|
||||||
errNotFoundTags = "no repository was found with the specified tags"
|
errNotFoundTags = "no repository was found with the specified tags"
|
||||||
errNotFoundName = "no repository was found with the specified name"
|
errNotFoundName = "no repository was found with the specified name"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GitRepositoryManager struct {
|
type GitRepositoryManager struct {
|
||||||
cliArguments config2.CliArguments
|
cliArguments config.CliArguments
|
||||||
configuration config2.Configuration
|
configuration config.Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitRepositoryManager) Parse(args []string) error {
|
func (g *GitRepositoryManager) Parse(args []string) error {
|
||||||
arguments, err := config2.ParseCliArguments(AppName, AppDescription, args)
|
arguments, err := config.ParseCliArguments(AppName, AppDescription, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error: %v", err.Error())
|
fmt.Printf("Error: %v", err.Error())
|
||||||
return err
|
return err
|
||||||
@ -42,7 +42,7 @@ func (g *GitRepositoryManager) Parse(args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration, err := config2.GetRepositoryConfig(configFileContent, fileExtension)
|
configuration, err := config.GetRepositoryConfig(configFileContent, fileExtension)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error: %v", err.Error())
|
fmt.Printf("Error: %v", err.Error())
|
||||||
return err
|
return err
|
||||||
@ -78,14 +78,14 @@ func (g *GitRepositoryManager) Run(w io.Writer) int {
|
|||||||
|
|
||||||
if g.cliArguments.Sync && exitCode == 0 {
|
if g.cliArguments.Sync && exitCode == 0 {
|
||||||
echo.InfoFMsg("Synchronizing repositories")
|
echo.InfoFMsg("Synchronizing repositories")
|
||||||
sync := commands2.NewSynchronizer(g.configuration.Workspace)
|
sync := commands.NewSynchronizer(g.configuration.Workspace)
|
||||||
g.runCommand(sync)
|
g.runCommand(sync)
|
||||||
echo.InfoFMsg("All repositories are synced")
|
echo.InfoFMsg("All repositories are synced")
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.cliArguments.Status && exitCode == 0 {
|
if g.cliArguments.Status && exitCode == 0 {
|
||||||
echo.InfoFMsg("Current status of repositories")
|
echo.InfoFMsg("Current status of repositories")
|
||||||
status := commands2.NewStatusChecker(g.configuration.Workspace)
|
status := commands.NewStatusChecker(g.configuration.Workspace)
|
||||||
g.runCommand(status)
|
g.runCommand(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ func (g *GitRepositoryManager) Run(w io.Writer) int {
|
|||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeStatus(status commands2.CommandStatus) {
|
func describeStatus(status commands.CommandStatus) {
|
||||||
if status.Error {
|
if status.Error {
|
||||||
echo.RedMessageF("Repository \"%v\": an error occurred: %v", status.Name, status.Message)
|
echo.RedMessageF("Repository \"%v\": an error occurred: %v", status.Name, status.Message)
|
||||||
return
|
return
|
||||||
@ -109,7 +109,7 @@ func describeStatus(status commands2.CommandStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitRepositoryManager) limitTags() error {
|
func (g *GitRepositoryManager) limitTags() error {
|
||||||
limitedTagsTmp := []config2.RepositoryConfig{}
|
limitedTagsTmp := []config.RepositoryConfig{}
|
||||||
|
|
||||||
for _, item := range g.configuration.Repositories {
|
for _, item := range g.configuration.Repositories {
|
||||||
if checkAnyOfItemInSlice(item.Tags, g.cliArguments.LimitToTags) {
|
if checkAnyOfItemInSlice(item.Tags, g.cliArguments.LimitToTags) {
|
||||||
@ -126,14 +126,14 @@ func (g *GitRepositoryManager) limitTags() error {
|
|||||||
func (g *GitRepositoryManager) limitName() error {
|
func (g *GitRepositoryManager) limitName() error {
|
||||||
for _, item := range g.configuration.Repositories {
|
for _, item := range g.configuration.Repositories {
|
||||||
if g.cliArguments.LimitToName == item.Name {
|
if g.cliArguments.LimitToName == item.Name {
|
||||||
g.configuration.Repositories = []config2.RepositoryConfig{item}
|
g.configuration.Repositories = []config.RepositoryConfig{item}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.New(errNotFoundName)
|
return errors.New(errNotFoundName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitRepositoryManager) runCommand(cmd commands2.Command) {
|
func (g *GitRepositoryManager) runCommand(cmd commands.Command) {
|
||||||
routines := make(chan struct{}, g.cliArguments.Routines)
|
routines := make(chan struct{}, g.cliArguments.Routines)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@ -145,7 +145,7 @@ func (g *GitRepositoryManager) runCommand(cmd commands2.Command) {
|
|||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
go func(r config2.RepositoryConfig) {
|
go func(r config.RepositoryConfig) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
routines <- struct{}{}
|
routines <- struct{}{}
|
||||||
describeStatus(cmd.Command(r))
|
describeStatus(cmd.Command(r))
|
||||||
|
Loading…
Reference in New Issue
Block a user