mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-12 16:43:49 +02:00
Merge branch 'main' of https://github.com/go-gitea/gitea into workflow-webhook-api
This commit is contained in:
commit
b650ca9239
80 files changed
+570
-284
No files matched your search
@@ -204,7 +204,7 @@ Loop:
|
||||
return false, "", nil, &ErrWontSign{twofa}
|
||||
}
|
||||
case parentSigned:
|
||||
gitRepo, err := gitrepo.OpenWikiRepository(ctx, repo)
|
||||
gitRepo, err := gitrepo.OpenRepository(ctx, repo.WikiStorageRepo())
|
||||
if err != nil {
|
||||
return false, "", nil, err
|
||||
}
|
||||
|
||||
@@ -49,14 +49,14 @@ func checkScriptType(ctx context.Context, logger log.Logger, autofix bool) error
|
||||
|
||||
func checkHooks(ctx context.Context, logger log.Logger, autofix bool) error {
|
||||
if err := iterateRepositories(ctx, func(repo *repo_model.Repository) error {
|
||||
results, err := gitrepo.CheckDelegateHooksForRepo(ctx, repo)
|
||||
results, err := gitrepo.CheckDelegateHooks(ctx, repo)
|
||||
if err != nil {
|
||||
logger.Critical("Unable to check delegate hooks for repo %-v. ERROR: %v", repo, err)
|
||||
return fmt.Errorf("Unable to check delegate hooks for repo %-v. ERROR: %w", repo, err)
|
||||
}
|
||||
if len(results) > 0 && autofix {
|
||||
logger.Warn("Regenerated hooks for %s", repo.FullName())
|
||||
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
|
||||
if err := gitrepo.CreateDelegateHooks(ctx, repo); err != nil {
|
||||
logger.Critical("Unable to recreate delegate hooks for %-v. ERROR: %v", repo, err)
|
||||
return fmt.Errorf("Unable to recreate delegate hooks for %-v. ERROR: %w", repo, err)
|
||||
}
|
||||
|
||||
@@ -13,9 +13,28 @@ import (
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
func userFeedCacheKey(userID int64) string {
|
||||
return fmt.Sprintf("user_feed_%d", userID)
|
||||
}
|
||||
|
||||
func GetFeedsForDashboard(ctx context.Context, opts activities_model.GetFeedsOptions) (activities_model.ActionList, int64, error) {
|
||||
opts.DontCount = opts.RequestedTeam == nil && opts.Date == ""
|
||||
results, cnt, err := activities_model.GetFeeds(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if opts.DontCount {
|
||||
cnt, err = cache.GetInt64(userFeedCacheKey(opts.Actor.ID), func() (int64, error) {
|
||||
return activities_model.CountUserFeeds(ctx, opts.Actor.ID)
|
||||
})
|
||||
}
|
||||
return results, cnt, err
|
||||
}
|
||||
|
||||
// GetFeeds returns actions according to the provided options
|
||||
func GetFeeds(ctx context.Context, opts activities_model.GetFeedsOptions) (activities_model.ActionList, int64, error) {
|
||||
return activities_model.GetFeeds(ctx, opts)
|
||||
@@ -68,6 +87,13 @@ func notifyWatchers(ctx context.Context, act *activities_model.Action, watchers
|
||||
if err := db.Insert(ctx, act); err != nil {
|
||||
return fmt.Errorf("insert new action: %w", err)
|
||||
}
|
||||
|
||||
total, err := activities_model.CountUserFeeds(ctx, act.UserID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("count user feeds: %w", err)
|
||||
}
|
||||
|
||||
_ = cache.GetCache().Put(userFeedCacheKey(act.UserID), fmt.Sprintf("%d", total), setting.CacheService.TTLSeconds())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -143,7 +143,7 @@ func runPushSync(ctx context.Context, m *repo_model.PushMirror) error {
|
||||
|
||||
var gitRepo *git.Repository
|
||||
if isWiki {
|
||||
gitRepo, err = gitrepo.OpenWikiRepository(ctx, repo)
|
||||
gitRepo, err = gitrepo.OpenRepository(ctx, repo.WikiStorageRepo())
|
||||
} else {
|
||||
gitRepo, err = gitrepo.OpenRepository(ctx, repo)
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func adoptRepository(ctx context.Context, repo *repo_model.Repository, defaultBr
|
||||
return fmt.Errorf("adoptRepository: path does not already exist: %s", repo.FullName())
|
||||
}
|
||||
|
||||
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
|
||||
if err := gitrepo.CreateDelegateHooks(ctx, repo); err != nil {
|
||||
return fmt.Errorf("createDelegateHooks: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
|
||||
return fmt.Errorf("git update-server-info: %w", err)
|
||||
}
|
||||
|
||||
if err = gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
|
||||
if err = gitrepo.CreateDelegateHooks(ctx, repo); err != nil {
|
||||
return fmt.Errorf("createDelegateHooks: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ func SyncRepositoryHooks(ctx context.Context) error {
|
||||
default:
|
||||
}
|
||||
|
||||
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
|
||||
if err := gitrepo.CreateDelegateHooks(ctx, repo); err != nil {
|
||||
return fmt.Errorf("SyncRepositoryHook: %w", err)
|
||||
}
|
||||
if repo.HasWiki() {
|
||||
if err := gitrepo.CreateDelegateHooksForWiki(ctx, repo); err != nil {
|
||||
if err := gitrepo.CreateDelegateHooks(ctx, repo.WikiStorageRepo()); err != nil {
|
||||
return fmt.Errorf("SyncRepositoryHook: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,11 +265,11 @@ func cleanUpMigrateGitConfig(ctx context.Context, repoPath string) error {
|
||||
|
||||
// CleanUpMigrateInfo finishes migrating repository and/or wiki with things that don't need to be done for mirrors.
|
||||
func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo_model.Repository, error) {
|
||||
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
|
||||
if err := gitrepo.CreateDelegateHooks(ctx, repo); err != nil {
|
||||
return repo, fmt.Errorf("createDelegateHooks: %w", err)
|
||||
}
|
||||
if repo.HasWiki() {
|
||||
if err := gitrepo.CreateDelegateHooksForWiki(ctx, repo); err != nil {
|
||||
if err := gitrepo.CreateDelegateHooks(ctx, repo.WikiStorageRepo()); err != nil {
|
||||
return repo, fmt.Errorf("createDelegateHooks.(wiki): %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
+111
-86
@@ -167,8 +167,9 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
branch := opts.RefFullName.BranchName()
|
||||
if !opts.IsDelRef() {
|
||||
branch := opts.RefFullName.BranchName()
|
||||
|
||||
log.Trace("TriggerTask '%s/%s' by %s", repo.Name, branch, pusher.Name)
|
||||
|
||||
newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
|
||||
@@ -176,60 +177,15 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||
return fmt.Errorf("gitRepo.GetCommit(%s) in %s/%s[%d]: %w", opts.NewCommitID, repo.OwnerName, repo.Name, repo.ID, err)
|
||||
}
|
||||
|
||||
refName := opts.RefName()
|
||||
|
||||
// Push new branch.
|
||||
var l []*git.Commit
|
||||
if opts.IsNewRef() {
|
||||
if repo.IsEmpty { // Change default branch and empty status only if pushed ref is non-empty branch.
|
||||
repo.DefaultBranch = refName
|
||||
repo.IsEmpty = false
|
||||
if repo.DefaultBranch != setting.Repository.DefaultBranch {
|
||||
if err := gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Update the is empty and default_branch columns
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "default_branch", "is_empty"); err != nil {
|
||||
return fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
l, err = newCommit.CommitsBeforeLimit(10)
|
||||
if err != nil {
|
||||
return fmt.Errorf("newCommit.CommitsBeforeLimit: %w", err)
|
||||
}
|
||||
notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID)
|
||||
l, err = pushNewBranch(ctx, repo, pusher, opts, newCommit)
|
||||
} else {
|
||||
l, err = newCommit.CommitsBeforeUntil(opts.OldCommitID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("newCommit.CommitsBeforeUntil: %w", err)
|
||||
}
|
||||
|
||||
isForcePush, err := newCommit.IsForcePush(opts.OldCommitID)
|
||||
if err != nil {
|
||||
log.Error("IsForcePush %s:%s failed: %v", repo.FullName(), branch, err)
|
||||
}
|
||||
|
||||
// only update branch can trigger pull request task because the pull request hasn't been created yet when creaing a branch
|
||||
go pull_service.AddTestPullRequestTask(pull_service.TestPullRequestOptions{
|
||||
RepoID: repo.ID,
|
||||
Doer: pusher,
|
||||
Branch: branch,
|
||||
IsSync: true,
|
||||
IsForcePush: isForcePush,
|
||||
OldCommitID: opts.OldCommitID,
|
||||
NewCommitID: opts.NewCommitID,
|
||||
})
|
||||
|
||||
if isForcePush {
|
||||
log.Trace("Push %s is a force push", opts.NewCommitID)
|
||||
|
||||
cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
|
||||
} else {
|
||||
// TODO: increment update the commit count cache but not remove
|
||||
cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
|
||||
}
|
||||
l, err = pushUpdateBranch(ctx, repo, pusher, opts, newCommit)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete cache for divergence
|
||||
@@ -246,36 +202,11 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||
commits := repo_module.GitToPushCommits(l)
|
||||
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
|
||||
|
||||
if err := issue_service.UpdateIssuesCommit(ctx, pusher, repo, commits.Commits, refName); err != nil {
|
||||
if err := issue_service.UpdateIssuesCommit(ctx, pusher, repo, commits.Commits, opts.RefName()); err != nil {
|
||||
log.Error("updateIssuesCommit: %v", err)
|
||||
}
|
||||
|
||||
oldCommitID := opts.OldCommitID
|
||||
if oldCommitID == objectFormat.EmptyObjectID().String() && len(commits.Commits) > 0 {
|
||||
oldCommit, err := gitRepo.GetCommit(commits.Commits[len(commits.Commits)-1].Sha1)
|
||||
if err != nil && !git.IsErrNotExist(err) {
|
||||
log.Error("unable to GetCommit %s from %-v: %v", oldCommitID, repo, err)
|
||||
}
|
||||
if oldCommit != nil {
|
||||
for i := 0; i < oldCommit.ParentCount(); i++ {
|
||||
commitID, _ := oldCommit.ParentID(i)
|
||||
if !commitID.IsZero() {
|
||||
oldCommitID = commitID.String()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if oldCommitID == objectFormat.EmptyObjectID().String() && repo.DefaultBranch != branch {
|
||||
oldCommitID = repo.DefaultBranch
|
||||
}
|
||||
|
||||
if oldCommitID != objectFormat.EmptyObjectID().String() {
|
||||
commits.CompareURL = repo.ComposeCompareURL(oldCommitID, opts.NewCommitID)
|
||||
} else {
|
||||
commits.CompareURL = ""
|
||||
}
|
||||
commits.CompareURL = getCompareURL(repo, gitRepo, objectFormat, commits.Commits, opts)
|
||||
|
||||
if len(commits.Commits) > setting.UI.FeedMaxCommitNum {
|
||||
commits.Commits = commits.Commits[:setting.UI.FeedMaxCommitNum]
|
||||
@@ -288,12 +219,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||
log.Error("repo_module.CacheRef %s/%s failed: %v", repo.ID, branch, err)
|
||||
}
|
||||
} else {
|
||||
notify_service.DeleteRef(ctx, pusher, repo, opts.RefFullName)
|
||||
|
||||
if err := pull_service.AdjustPullsCausedByBranchDeleted(ctx, pusher, repo, branch); err != nil {
|
||||
// close all related pulls
|
||||
log.Error("close related pull request failed: %v", err)
|
||||
}
|
||||
pushDeleteBranch(ctx, repo, pusher, opts)
|
||||
}
|
||||
|
||||
// Even if user delete a branch on a repository which he didn't watch, he will be watch that.
|
||||
@@ -304,8 +230,11 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||
log.Trace("Non-tag and non-branch commits pushed.")
|
||||
}
|
||||
}
|
||||
if err := PushUpdateAddDeleteTags(ctx, repo, gitRepo, addTags, delTags); err != nil {
|
||||
return fmt.Errorf("PushUpdateAddDeleteTags: %w", err)
|
||||
|
||||
if len(addTags)+len(delTags) > 0 {
|
||||
if err := PushUpdateAddDeleteTags(ctx, repo, gitRepo, addTags, delTags); err != nil {
|
||||
return fmt.Errorf("PushUpdateAddDeleteTags: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Change repository last updated time.
|
||||
@@ -316,6 +245,102 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCompareURL(repo *repo_model.Repository, gitRepo *git.Repository, objectFormat git.ObjectFormat, commits []*repo_module.PushCommit, opts *repo_module.PushUpdateOptions) string {
|
||||
oldCommitID := opts.OldCommitID
|
||||
if oldCommitID == objectFormat.EmptyObjectID().String() && len(commits) > 0 {
|
||||
oldCommit, err := gitRepo.GetCommit(commits[len(commits)-1].Sha1)
|
||||
if err != nil && !git.IsErrNotExist(err) {
|
||||
log.Error("unable to GetCommit %s from %-v: %v", oldCommitID, repo, err)
|
||||
}
|
||||
if oldCommit != nil {
|
||||
for i := 0; i < oldCommit.ParentCount(); i++ {
|
||||
commitID, _ := oldCommit.ParentID(i)
|
||||
if !commitID.IsZero() {
|
||||
oldCommitID = commitID.String()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if oldCommitID == objectFormat.EmptyObjectID().String() && repo.DefaultBranch != opts.RefFullName.BranchName() {
|
||||
oldCommitID = repo.DefaultBranch
|
||||
}
|
||||
|
||||
if oldCommitID != objectFormat.EmptyObjectID().String() {
|
||||
return repo.ComposeCompareURL(oldCommitID, opts.NewCommitID)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func pushNewBranch(ctx context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions, newCommit *git.Commit) ([]*git.Commit, error) {
|
||||
if repo.IsEmpty { // Change default branch and empty status only if pushed ref is non-empty branch.
|
||||
repo.DefaultBranch = opts.RefName()
|
||||
repo.IsEmpty = false
|
||||
if repo.DefaultBranch != setting.Repository.DefaultBranch {
|
||||
if err := gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// Update the is empty and default_branch columns
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "default_branch", "is_empty"); err != nil {
|
||||
return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
l, err := newCommit.CommitsBeforeLimit(10)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("newCommit.CommitsBeforeLimit: %w", err)
|
||||
}
|
||||
notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID)
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func pushUpdateBranch(_ context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions, newCommit *git.Commit) ([]*git.Commit, error) {
|
||||
l, err := newCommit.CommitsBeforeUntil(opts.OldCommitID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("newCommit.CommitsBeforeUntil: %w", err)
|
||||
}
|
||||
|
||||
branch := opts.RefFullName.BranchName()
|
||||
|
||||
isForcePush, err := newCommit.IsForcePush(opts.OldCommitID)
|
||||
if err != nil {
|
||||
log.Error("IsForcePush %s:%s failed: %v", repo.FullName(), branch, err)
|
||||
}
|
||||
|
||||
// only update branch can trigger pull request task because the pull request hasn't been created yet when creating a branch
|
||||
go pull_service.AddTestPullRequestTask(pull_service.TestPullRequestOptions{
|
||||
RepoID: repo.ID,
|
||||
Doer: pusher,
|
||||
Branch: branch,
|
||||
IsSync: true,
|
||||
IsForcePush: isForcePush,
|
||||
OldCommitID: opts.OldCommitID,
|
||||
NewCommitID: opts.NewCommitID,
|
||||
})
|
||||
|
||||
if isForcePush {
|
||||
log.Trace("Push %s is a force push", opts.NewCommitID)
|
||||
|
||||
cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
|
||||
} else {
|
||||
// TODO: increment update the commit count cache but not remove
|
||||
cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func pushDeleteBranch(ctx context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions) {
|
||||
notify_service.DeleteRef(ctx, pusher, repo, opts.RefFullName)
|
||||
|
||||
if err := pull_service.AdjustPullsCausedByBranchDeleted(ctx, pusher, repo, opts.RefFullName.BranchName()); err != nil {
|
||||
// close all related pulls
|
||||
log.Error("close related pull request failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// PushUpdateAddDeleteTags updates a number of added and delete tags
|
||||
func PushUpdateAddDeleteTags(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, addTags, delTags []string) error {
|
||||
return db.WithTx(ctx, func(ctx context.Context) error {
|
||||
|
||||
@@ -331,12 +331,13 @@ func changeRepositoryName(ctx context.Context, repo *repo_model.Repository, newR
|
||||
return fmt.Errorf("IsRepositoryExist: %w", err)
|
||||
} else if has {
|
||||
return repo_model.ErrRepoAlreadyExist{
|
||||
Uname: repo.Owner.Name,
|
||||
Uname: repo.OwnerName,
|
||||
Name: newRepoName,
|
||||
}
|
||||
}
|
||||
|
||||
if err = gitrepo.RenameRepository(ctx, repo, newRepoName); err != nil {
|
||||
if err = gitrepo.RenameRepository(ctx, repo,
|
||||
repo_model.StorageRepo(repo_model.RelativePath(repo.OwnerName, newRepoName))); err != nil {
|
||||
return fmt.Errorf("rename repository directory: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func InitWiki(ctx context.Context, repo *repo_model.Repository) error {
|
||||
|
||||
if err := git.InitRepository(ctx, repo.WikiPath(), true, repo.ObjectFormatName); err != nil {
|
||||
return fmt.Errorf("InitRepository: %w", err)
|
||||
} else if err = gitrepo.CreateDelegateHooksForWiki(ctx, repo); err != nil {
|
||||
} else if err = gitrepo.CreateDelegateHooks(ctx, repo.WikiStorageRepo()); err != nil {
|
||||
return fmt.Errorf("createDelegateHooks: %w", err)
|
||||
} else if _, _, err = git.NewCommand("symbolic-ref", "HEAD").AddDynamicArguments(git.BranchPrefix+repo.DefaultWikiBranch).RunStdString(ctx, &git.RunOpts{Dir: repo.WikiPath()}); err != nil {
|
||||
return fmt.Errorf("unable to set default wiki branch to %q: %w", repo.DefaultWikiBranch, err)
|
||||
@@ -100,7 +100,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
|
||||
return fmt.Errorf("InitWiki: %w", err)
|
||||
}
|
||||
|
||||
hasDefaultBranch := gitrepo.IsWikiBranchExist(ctx, repo, repo.DefaultWikiBranch)
|
||||
hasDefaultBranch := gitrepo.IsBranchExist(ctx, repo.WikiStorageRepo(), repo.DefaultWikiBranch)
|
||||
|
||||
basePath, err := repo_module.CreateTemporaryPath("update-wiki")
|
||||
if err != nil {
|
||||
@@ -381,7 +381,7 @@ func ChangeDefaultWikiBranch(ctx context.Context, repo *repo_model.Repository, n
|
||||
return nil
|
||||
}
|
||||
|
||||
oldDefBranch, err := gitrepo.GetWikiDefaultBranch(ctx, repo)
|
||||
oldDefBranch, err := gitrepo.GetDefaultBranch(ctx, repo.WikiStorageRepo())
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get default branch: %w", err)
|
||||
}
|
||||
@@ -389,7 +389,7 @@ func ChangeDefaultWikiBranch(ctx context.Context, repo *repo_model.Repository, n
|
||||
return nil
|
||||
}
|
||||
|
||||
gitRepo, err := gitrepo.OpenWikiRepository(ctx, repo)
|
||||
gitRepo, err := gitrepo.OpenRepository(ctx, repo.WikiStorageRepo())
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
return nil // no git repo on storage, no need to do anything else
|
||||
} else if err != nil {
|
||||
|
||||
@@ -166,7 +166,7 @@ func TestRepository_AddWikiPage(t *testing.T) {
|
||||
webPath := UserTitleToWebPath("", userTitle)
|
||||
assert.NoError(t, AddWikiPage(git.DefaultContext, doer, repo, webPath, wikiContent, commitMsg))
|
||||
// Now need to show that the page has been added:
|
||||
gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo)
|
||||
gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo.WikiStorageRepo())
|
||||
require.NoError(t, err)
|
||||
|
||||
defer gitRepo.Close()
|
||||
@@ -213,7 +213,7 @@ func TestRepository_EditWikiPage(t *testing.T) {
|
||||
assert.NoError(t, EditWikiPage(git.DefaultContext, doer, repo, "Home", webPath, newWikiContent, commitMsg))
|
||||
|
||||
// Now need to show that the page has been added:
|
||||
gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo)
|
||||
gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo.WikiStorageRepo())
|
||||
assert.NoError(t, err)
|
||||
masterTree, err := gitRepo.GetTree(repo.DefaultWikiBranch)
|
||||
assert.NoError(t, err)
|
||||
@@ -237,7 +237,7 @@ func TestRepository_DeleteWikiPage(t *testing.T) {
|
||||
assert.NoError(t, DeleteWikiPage(git.DefaultContext, doer, repo, "Home"))
|
||||
|
||||
// Now need to show that the page has been added:
|
||||
gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo)
|
||||
gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo.WikiStorageRepo())
|
||||
require.NoError(t, err)
|
||||
|
||||
defer gitRepo.Close()
|
||||
@@ -251,7 +251,7 @@ func TestRepository_DeleteWikiPage(t *testing.T) {
|
||||
func TestPrepareWikiFileName(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo)
|
||||
gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo.WikiStorageRepo())
|
||||
require.NoError(t, err)
|
||||
|
||||
defer gitRepo.Close()
|
||||
|
||||
Reference in new issue
Block a user