Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions repository/repository_auth.go → repository/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"

"github.com/utilitywarehouse/git-mirror/auth"
Expand Down Expand Up @@ -46,7 +47,8 @@ func (r *Repository) authEnv(ctx context.Context) []string {

// if github app config is set use that token
case r.auth.GithubAppInstallationID != "" && r.gitURL.Host == "github.com":
token, err := r.getGithubAppToken(ctx, r.gitURL.Repo)
// github matches repo name without `.git` for permission for token req
token, err := r.getGithubAppToken(ctx, strings.TrimSuffix(r.gitURL.Repo, ".git"))
if err != nil {
r.log.Error("unable to get github app token", "err", err)
return nil
Expand Down Expand Up @@ -116,7 +118,7 @@ func (r *Repository) getGithubAppToken(ctx context.Context, repo string) (string
r.auth.GithubAppID, r.auth.GithubAppInstallationID, r.auth.GithubAppPrivateKeyPath,
permissions)
if err != nil {
return "", nil
return "", err
}

r.githubAppToken = token.Token
Expand Down
3 changes: 3 additions & 0 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,9 @@ func (r *Repository) removeStaleWorktreeLinks() bool {
onDiskTrackedLinks := make(map[string]string)
dirents, err := os.ReadDir(r.worktreesRoot())
if err != nil {
if strings.Contains(err.Error(), "no such file or directory") {
return success
}
r.log.Error("unable to read link worktree root dir", "err", err)
return false
}
Expand Down