3 Commits

Author SHA1 Message Date
  TheFox0x7 3bb0770160
fix nilnil in onedev downloader (#36154) 19 hours ago
  a1012112796 822ee60bae
fix webAuthn insecure error view (#36165) 1 day ago
  Lunny Xiao da087270ff
Some small refactors (#36163) 1 day ago
9 changed files with 21 additions and 29 deletions
Split View
  1. +2
    -2
      cmd/admin_auth_ldap_test.go
  2. +2
    -2
      modules/gitrepo/gitrepo.go
  3. +6
    -8
      services/doctor/checkOldArchives.go
  4. +1
    -1
      services/doctor/misc.go
  5. +7
    -7
      services/migrations/onedev.go
  6. +1
    -1
      services/pull/compare.go
  7. +0
    -1
      services/repository/branch.go
  8. +1
    -1
      services/repository/repository.go
  9. +1
    -6
      web_src/js/features/user-auth-webauthn.ts

+ 2
- 2
cmd/admin_auth_ldap_test.go View File

@@ -233,7 +233,7 @@ func TestAddLdapBindDn(t *testing.T) {
},
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
assert.FailNow(t, "getAuthSourceByID called", "case %d: should not call getAuthSourceByID", n)
return nil, nil
return nil, nil //nolint:nilnil // mock function covering improper behavior
},
}

@@ -463,7 +463,7 @@ func TestAddLdapSimpleAuth(t *testing.T) {
},
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
assert.FailNow(t, "getAuthSourceById called", "case %d: should not call getAuthSourceByID", n)
return nil, nil
return nil, nil //nolint:nilnil // mock function covering improper behavior
},
}



+ 2
- 2
modules/gitrepo/gitrepo.go View File

@@ -109,8 +109,8 @@ func IsRepoDirExist(ctx context.Context, repo Repository, relativeDirPath string
return util.IsDir(absoluteDirPath)
}

func RemoveRepoFile(ctx context.Context, repo Repository, relativeFilePath string) error {
absoluteFilePath := filepath.Join(repoPath(repo), relativeFilePath)
func RemoveRepoFileOrDir(ctx context.Context, repo Repository, relativeFileOrDirPath string) error {
absoluteFilePath := filepath.Join(repoPath(repo), relativeFileOrDirPath)
return util.Remove(absoluteFilePath)
}



+ 6
- 8
services/doctor/checkOldArchives.go View File

@@ -5,12 +5,10 @@ package doctor

import (
"context"
"os"
"path/filepath"

repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/gitrepo"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
)

func checkOldArchives(ctx context.Context, logger log.Logger, autofix bool) error {
@@ -21,18 +19,18 @@ func checkOldArchives(ctx context.Context, logger log.Logger, autofix bool) erro
return nil
}

p := filepath.Join(repo.RepoPath(), "archives")
isDir, err := util.IsDir(p)
isDir, err := gitrepo.IsRepoDirExist(ctx, repo, "archives")
if err != nil {
log.Warn("check if %s is directory failed: %v", p, err)
log.Warn("check if %s is directory failed: %v", repo.FullName(), err)
}
if isDir {
numRepos++
if autofix {
if err := os.RemoveAll(p); err == nil {
err := gitrepo.RemoveRepoFileOrDir(ctx, repo, "archives")
if err == nil {
numReposUpdated++
} else {
log.Warn("remove %s failed: %v", p, err)
log.Warn("remove %s failed: %v", repo.FullName(), err)
}
}
}


+ 1
- 1
services/doctor/misc.go View File

@@ -151,7 +151,7 @@ func checkDaemonExport(ctx context.Context, logger log.Logger, autofix bool) err
numNeedUpdate++
if autofix {
if !isPublic && isExist {
if err = gitrepo.RemoveRepoFile(ctx, repo, daemonExportFile); err != nil {
if err = gitrepo.RemoveRepoFileOrDir(ctx, repo, daemonExportFile); err != nil {
log.Error("Failed to remove %s:%s: %v", repo.FullName(), daemonExportFile, err)
}
} else if isPublic && !isExist {


+ 7
- 7
services/migrations/onedev.go View File

@@ -77,19 +77,19 @@ type OneDevDownloader struct {
}

// NewOneDevDownloader creates a new downloader
func NewOneDevDownloader(_ context.Context, baseURL *url.URL, username, password, repoPath string) *OneDevDownloader {
func NewOneDevDownloader(ctx context.Context, baseURL *url.URL, username, password, repoPath string) *OneDevDownloader {
httpTransport := NewMigrationHTTPTransport()
downloader := &OneDevDownloader{
baseURL: baseURL,
repoPath: repoPath,
client: &http.Client{
Transport: &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
if len(username) > 0 && len(password) > 0 {
Transport: roundTripperFunc(
func(req *http.Request) (*http.Response, error) {
if username != "" && password != "" {
req.SetBasicAuth(username, password)
}
return nil, nil
},
},
return httpTransport.RoundTrip(req.WithContext(ctx))
}),
},
userMap: make(map[int64]*onedevUser),
milestoneMap: make(map[int64]string),


+ 1
- 1
services/pull/compare.go View File

@@ -33,7 +33,7 @@ func GetCompareInfo(ctx context.Context, baseRepo, headRepo *repo_model.Reposito
)

// We don't need a temporary remote for same repository.
if headGitRepo.Path != baseRepo.RepoPath() {
if baseRepo.ID != headRepo.ID {
// Add a temporary remote
tmpRemote = strconv.FormatInt(time.Now().UnixNano(), 10)
if err = gitrepo.GitRemoteAdd(ctx, headRepo, tmpRemote, baseRepo.RepoPath()); err != nil {


+ 0
- 1
services/repository/branch.go View File

@@ -526,7 +526,6 @@ func UpdateBranch(ctx context.Context, repo *repo_model.Repository, gitRepo *git
}

pushOpts := git.PushOptions{
Remote: repo.RepoPath(),
Branch: fmt.Sprintf("%s:%s%s", newCommit.ID.String(), git.BranchPrefix, branchName),
Env: repo_module.PushingEnvironment(doer, repo),
Force: isForcePush || force,


+ 1
- 1
services/repository/repository.go View File

@@ -257,7 +257,7 @@ func CheckDaemonExportOK(ctx context.Context, repo *repo_model.Repository) error

isPublic := !repo.IsPrivate && repo.Owner.Visibility == structs.VisibleTypePublic
if !isPublic && isExist {
if err = gitrepo.RemoveRepoFile(ctx, repo, daemonExportFile); err != nil {
if err = gitrepo.RemoveRepoFileOrDir(ctx, repo, daemonExportFile); err != nil {
log.Error("Failed to remove %s: %v", daemonExportFile, err)
}
} else if isPublic && !isExist {


+ 1
- 6
web_src/js/features/user-auth-webauthn.ts View File

@@ -11,13 +11,8 @@ export async function initUserAuthWebAuthn() {
return;
}

// webauthn is only supported on secure contexts
if (!window.isSecureContext) {
if (elSignInPasskeyBtn) hideElem(elSignInPasskeyBtn);
return;
}

if (!detectWebAuthnSupport()) {
if (elSignInPasskeyBtn) hideElem(elSignInPasskeyBtn);
return;
}



Loading…
Cancel
Save
Baidu
map