Skip to content

Commit

Permalink
simplify IsArchived call
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Magee <[email protected]>
  • Loading branch information
JamieMagee committed Nov 12, 2024
1 parent dc61385 commit 6044d50
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions clients/azuredevopsrepo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"io"
"os"
"strings"
"sync"
"time"

"github.com/microsoft/azure-devops-go-api/azuredevops/v7"
Expand All @@ -40,10 +39,10 @@ type Client struct {
azdoClient git.Client
ctx context.Context
repourl *Repo
repo *git.GitRepository
branches *branchesHandler
commits *commitsHandler
commitDepth int
once sync.Once
}

func (c *Client) InitRepo(inputRepo clients.Repo, commitSHA string, commitDepth int) error {
Expand Down Expand Up @@ -91,25 +90,7 @@ func (c *Client) URI() string {
}

func (c *Client) IsArchived() (bool, error) {
var (
isArchived bool
isArchivedErr error
)

c.once.Do(func() {
repo, err := c.azdoClient.GetRepository(c.ctx, git.GetRepositoryArgs{RepositoryId: &c.repourl.id})
if err != nil {
isArchivedErr = fmt.Errorf("could not get repository with error: %w", err)
return
}
isArchived = *repo.IsDisabled
})

if isArchivedErr != nil {
return false, isArchivedErr
}

return isArchived, nil
return *c.repo.IsDisabled, nil
}

func (c *Client) ListFiles(predicate func(string) (bool, error)) ([]string, error) {
Expand Down Expand Up @@ -137,7 +118,7 @@ func (c *Client) GetDefaultBranchName() (string, error) {
return c.repourl.defaultBranch, nil
}

return "", fmt.Errorf("%w", errDefaultBranchNotFound)
return "", errDefaultBranchNotFound
}

func (c *Client) GetDefaultBranch() (*clients.BranchRef, error) {
Expand Down

0 comments on commit 6044d50

Please sign in to comment.