Improve tests stability
This commit is contained in:
parent
d7615a90ba
commit
806ff9b4c1
@ -2,11 +2,11 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitlab.com/revalus/grm/internal/config"
|
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
"github.com/go-git/go-git/v5/plumbing/object"
|
||||||
|
"gitlab.com/revalus/grm/internal/config"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatusChecker struct {
|
type StatusChecker struct {
|
||||||
@ -116,14 +116,14 @@ func (sc StatusChecker) Command(repoCfg config.RepositoryConfig) CommandStatus {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
remotesStatus := make(map[string]remoteStatus)
|
var remoteNames []string
|
||||||
|
remoteStatues := make(map[string]remoteStatus)
|
||||||
|
|
||||||
for _, remote := range remotes {
|
for _, remote := range remotes {
|
||||||
remoteName := remote.Config().Name
|
remoteName := remote.Config().Name
|
||||||
|
|
||||||
remoteRevision, err := repo.ResolveRevision(plumbing.Revision(fmt.Sprintf("%v/%v", remoteName, headReference.Name().Short())))
|
remoteRevision, err := repo.ResolveRevision(plumbing.Revision(fmt.Sprintf("%v/%v", remoteName, headReference.Name().Short())))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remotesStatus[remoteName] = remoteStatus{
|
remoteStatues[remoteName] = remoteStatus{
|
||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -131,7 +131,7 @@ func (sc StatusChecker) Command(repoCfg config.RepositoryConfig) CommandStatus {
|
|||||||
|
|
||||||
remoteBranchCommit, err := repo.CommitObject(*remoteRevision)
|
remoteBranchCommit, err := repo.CommitObject(*remoteRevision)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remotesStatus[remoteName] = remoteStatus{
|
remoteStatues[remoteName] = remoteStatus{
|
||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -144,11 +144,14 @@ func (sc StatusChecker) Command(repoCfg config.RepositoryConfig) CommandStatus {
|
|||||||
if status.ahead > 0 || status.behind > 0 {
|
if status.ahead > 0 || status.behind > 0 {
|
||||||
cmdStatus.Changed = true
|
cmdStatus.Changed = true
|
||||||
}
|
}
|
||||||
remotesStatus[remoteName] = status
|
remoteNames = append(remoteNames, remoteName)
|
||||||
|
remoteStatues[remoteName] = status
|
||||||
|
|
||||||
}
|
}
|
||||||
|
sort.Strings(remoteNames)
|
||||||
cmdStatus.Message = fmt.Sprintf("branch %v", headReference.Name().Short())
|
cmdStatus.Message = fmt.Sprintf("branch %v", headReference.Name().Short())
|
||||||
for remoteName, status := range remotesStatus {
|
for _, remoteName := range remoteNames {
|
||||||
|
status := remoteStatues[remoteName]
|
||||||
if status.err != nil {
|
if status.err != nil {
|
||||||
cmdStatus.Message = fmt.Sprintf("%v - ( | %v | problem: %v )", cmdStatus.Message, remoteName, status.err.Error())
|
cmdStatus.Message = fmt.Sprintf("%v - ( | %v | problem: %v )", cmdStatus.Message, remoteName, status.err.Error())
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user