Skip to content

Commit 4198e43

Browse files
authored
Merge branch 'main' into tooldeps-8
2 parents e935001 + 7fd44a8 commit 4198e43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+121
-160
lines changed

modules/repository/hooks.go renamed to modules/gitrepo/hooks.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Copyright 2020 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package repository
4+
package gitrepo
55

66
import (
7+
"context"
78
"fmt"
89
"os"
910
"path/filepath"
@@ -105,10 +106,18 @@ done
105106
return hookNames, hookTpls, giteaHookTpls
106107
}
107108

108-
// CreateDelegateHooks creates all the hooks scripts for the repo
109-
func CreateDelegateHooks(repoPath string) (err error) {
109+
// CreateDelegateHooksForRepo creates all the hooks scripts for the repo
110+
func CreateDelegateHooksForRepo(_ context.Context, repo Repository) (err error) {
111+
return createDelegateHooks(filepath.Join(repoPath(repo), "hooks"))
112+
}
113+
114+
// CreateDelegateHooksForWiki creates all the hooks scripts for the wiki repo
115+
func CreateDelegateHooksForWiki(_ context.Context, repo Repository) (err error) {
116+
return createDelegateHooks(filepath.Join(wikiPath(repo), "hooks"))
117+
}
118+
119+
func createDelegateHooks(hookDir string) (err error) {
110120
hookNames, hookTpls, giteaHookTpls := getHookTemplates()
111-
hookDir := filepath.Join(repoPath, "hooks")
112121

113122
for i, hookName := range hookNames {
114123
oldHookPath := filepath.Join(hookDir, hookName)
@@ -169,11 +178,19 @@ func ensureExecutable(filename string) error {
169178
return os.Chmod(filename, mode)
170179
}
171180

172-
// CheckDelegateHooks checks the hooks scripts for the repo
173-
func CheckDelegateHooks(repoPath string) ([]string, error) {
181+
// CheckDelegateHooksForRepo checks the hooks scripts for the repo
182+
func CheckDelegateHooksForRepo(_ context.Context, repo Repository) ([]string, error) {
183+
return checkDelegateHooks(filepath.Join(repoPath(repo), "hooks"))
184+
}
185+
186+
// CheckDelegateHooksForWiki checks the hooks scripts for the repo
187+
func CheckDelegateHooksForWiki(_ context.Context, repo Repository) ([]string, error) {
188+
return checkDelegateHooks(filepath.Join(wikiPath(repo), "hooks"))
189+
}
190+
191+
func checkDelegateHooks(hookDir string) ([]string, error) {
174192
hookNames, hookTpls, giteaHookTpls := getHookTemplates()
175193

176-
hookDir := filepath.Join(repoPath, "hooks")
177194
results := make([]string, 0, 10)
178195

179196
for i, hookName := range hookNames {

modules/repository/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func CheckInitRepository(ctx context.Context, repo *repo_model.Repository) (err
138138
// Init git bare new repository.
139139
if err = git.InitRepository(ctx, repo.RepoPath(), true, repo.ObjectFormatName); err != nil {
140140
return fmt.Errorf("git.InitRepository: %w", err)
141-
} else if err = CreateDelegateHooks(repo.RepoPath()); err != nil {
141+
} else if err = gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
142142
return fmt.Errorf("createDelegateHooks: %w", err)
143143
}
144144
return nil

services/doctor/misc.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"code.gitea.io/gitea/modules/git"
1919
"code.gitea.io/gitea/modules/gitrepo"
2020
"code.gitea.io/gitea/modules/log"
21-
"code.gitea.io/gitea/modules/repository"
2221
"code.gitea.io/gitea/modules/setting"
2322
"code.gitea.io/gitea/modules/structs"
2423
"code.gitea.io/gitea/modules/util"
@@ -50,14 +49,14 @@ func checkScriptType(ctx context.Context, logger log.Logger, autofix bool) error
5049

5150
func checkHooks(ctx context.Context, logger log.Logger, autofix bool) error {
5251
if err := iterateRepositories(ctx, func(repo *repo_model.Repository) error {
53-
results, err := repository.CheckDelegateHooks(repo.RepoPath())
52+
results, err := gitrepo.CheckDelegateHooksForRepo(ctx, repo)
5453
if err != nil {
5554
logger.Critical("Unable to check delegate hooks for repo %-v. ERROR: %v", repo, err)
5655
return fmt.Errorf("Unable to check delegate hooks for repo %-v. ERROR: %w", repo, err)
5756
}
5857
if len(results) > 0 && autofix {
5958
logger.Warn("Regenerated hooks for %s", repo.FullName())
60-
if err := repository.CreateDelegateHooks(repo.RepoPath()); err != nil {
59+
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
6160
logger.Critical("Unable to recreate delegate hooks for %-v. ERROR: %v", repo, err)
6261
return fmt.Errorf("Unable to recreate delegate hooks for %-v. ERROR: %w", repo, err)
6362
}

services/repository/adopt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func adoptRepository(ctx context.Context, repo *repo_model.Repository, defaultBr
115115
return fmt.Errorf("adoptRepository: path does not already exist: %s", repo.FullName())
116116
}
117117

118-
if err := repo_module.CreateDelegateHooks(repo.RepoPath()); err != nil {
118+
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
119119
return fmt.Errorf("createDelegateHooks: %w", err)
120120
}
121121

services/repository/fork.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
154154
if opts.SingleBranch != "" {
155155
cloneCmd.AddArguments("--single-branch", "--branch").AddDynamicArguments(opts.SingleBranch)
156156
}
157-
repoPath := repo_model.RepoPath(owner.Name, repo.Name)
158-
if stdout, _, err := cloneCmd.AddDynamicArguments(oldRepoPath, repoPath).
157+
if stdout, _, err := cloneCmd.AddDynamicArguments(oldRepoPath, repo.RepoPath()).
159158
RunStdBytes(txCtx, &git.RunOpts{Timeout: 10 * time.Minute}); err != nil {
160159
log.Error("Fork Repository (git clone) Failed for %v (from %v):\nStdout: %s\nError: %v", repo, opts.BaseRepo, stdout, err)
161160
return fmt.Errorf("git clone: %w", err)
@@ -166,12 +165,12 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
166165
}
167166

168167
if stdout, _, err := git.NewCommand("update-server-info").
169-
RunStdString(txCtx, &git.RunOpts{Dir: repoPath}); err != nil {
168+
RunStdString(txCtx, &git.RunOpts{Dir: repo.RepoPath()}); err != nil {
170169
log.Error("Fork Repository (git update-server-info) failed for %v:\nStdout: %s\nError: %v", repo, stdout, err)
171170
return fmt.Errorf("git update-server-info: %w", err)
172171
}
173172

174-
if err = repo_module.CreateDelegateHooks(repoPath); err != nil {
173+
if err = gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
175174
return fmt.Errorf("createDelegateHooks: %w", err)
176175
}
177176

services/repository/hooks.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"code.gitea.io/gitea/models/webhook"
1313
"code.gitea.io/gitea/modules/gitrepo"
1414
"code.gitea.io/gitea/modules/log"
15-
repo_module "code.gitea.io/gitea/modules/repository"
1615

1716
"xorm.io/builder"
1817
)
@@ -32,11 +31,11 @@ func SyncRepositoryHooks(ctx context.Context) error {
3231
default:
3332
}
3433

35-
if err := repo_module.CreateDelegateHooks(repo.RepoPath()); err != nil {
34+
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
3635
return fmt.Errorf("SyncRepositoryHook: %w", err)
3736
}
3837
if repo.HasWiki() {
39-
if err := repo_module.CreateDelegateHooks(repo.WikiPath()); err != nil {
38+
if err := gitrepo.CreateDelegateHooksForWiki(ctx, repo); err != nil {
4039
return fmt.Errorf("SyncRepositoryHook: %w", err)
4140
}
4241
}

services/repository/migrate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
repo_model "code.gitea.io/gitea/models/repo"
1616
user_model "code.gitea.io/gitea/models/user"
1717
"code.gitea.io/gitea/modules/git"
18+
"code.gitea.io/gitea/modules/gitrepo"
1819
"code.gitea.io/gitea/modules/lfs"
1920
"code.gitea.io/gitea/modules/log"
2021
"code.gitea.io/gitea/modules/migration"
@@ -264,17 +265,16 @@ func cleanUpMigrateGitConfig(ctx context.Context, repoPath string) error {
264265

265266
// CleanUpMigrateInfo finishes migrating repository and/or wiki with things that don't need to be done for mirrors.
266267
func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo_model.Repository, error) {
267-
repoPath := repo.RepoPath()
268-
if err := repo_module.CreateDelegateHooks(repoPath); err != nil {
268+
if err := gitrepo.CreateDelegateHooksForRepo(ctx, repo); err != nil {
269269
return repo, fmt.Errorf("createDelegateHooks: %w", err)
270270
}
271271
if repo.HasWiki() {
272-
if err := repo_module.CreateDelegateHooks(repo.WikiPath()); err != nil {
272+
if err := gitrepo.CreateDelegateHooksForWiki(ctx, repo); err != nil {
273273
return repo, fmt.Errorf("createDelegateHooks.(wiki): %w", err)
274274
}
275275
}
276276

277-
_, _, err := git.NewCommand("remote", "rm", "origin").RunStdString(ctx, &git.RunOpts{Dir: repoPath})
277+
_, _, err := git.NewCommand("remote", "rm", "origin").RunStdString(ctx, &git.RunOpts{Dir: repo.RepoPath()})
278278
if err != nil && !git.IsRemoteNotExistError(err) {
279279
return repo, fmt.Errorf("CleanUpMigrateInfo: %w", err)
280280
}

services/wiki/wiki.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func InitWiki(ctx context.Context, repo *repo_model.Repository) error {
4141

4242
if err := git.InitRepository(ctx, repo.WikiPath(), true, repo.ObjectFormatName); err != nil {
4343
return fmt.Errorf("InitRepository: %w", err)
44-
} else if err = repo_module.CreateDelegateHooks(repo.WikiPath()); err != nil {
44+
} else if err = gitrepo.CreateDelegateHooksForWiki(ctx, repo); err != nil {
4545
return fmt.Errorf("createDelegateHooks: %w", err)
4646
} else if _, _, err = git.NewCommand("symbolic-ref", "HEAD").AddDynamicArguments(git.BranchPrefix+repo.DefaultWikiBranch).RunStdString(ctx, &git.RunOpts{Dir: repo.WikiPath()}); err != nil {
4747
return fmt.Errorf("unable to set default wiki branch to %q: %w", repo.DefaultWikiBranch, err)

templates/admin/dashboard.tmpl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,57 @@
1515
<tbody>
1616
<tr>
1717
<td>{{ctx.Locale.Tr "admin.dashboard.delete_inactive_accounts"}}</td>
18-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="delete_inactive_accounts">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
18+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="delete_inactive_accounts">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
1919
</tr>
2020
<tr>
2121
<td>{{ctx.Locale.Tr "admin.dashboard.delete_repo_archives"}}</td>
22-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="delete_repo_archives">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
22+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="delete_repo_archives">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
2323
</tr>
2424
<tr>
2525
<td>{{ctx.Locale.Tr "admin.dashboard.delete_missing_repos"}}</td>
26-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="delete_missing_repos">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
26+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="delete_missing_repos">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
2727
</tr>
2828
<tr>
2929
<td>{{ctx.Locale.Tr "admin.dashboard.git_gc_repos"}}</td>
30-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="git_gc_repos">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
30+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="git_gc_repos">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
3131
</tr>
3232
{{if and (not .SSH.Disabled) (not .SSH.StartBuiltinServer)}}
3333
<tr>
3434
<td>{{ctx.Locale.Tr "admin.dashboard.resync_all_sshkeys"}}</td>
35-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="resync_all_sshkeys">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
35+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="resync_all_sshkeys">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
3636
</tr>
3737
<tr>
3838
<td>{{ctx.Locale.Tr "admin.dashboard.resync_all_sshprincipals"}}</td>
39-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="resync_all_sshprincipals">{{svg "octicon-play" 16}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
39+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="resync_all_sshprincipals">{{svg "octicon-play" 16}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
4040
</tr>
4141
{{end}}
4242
<tr>
4343
<td>{{ctx.Locale.Tr "admin.dashboard.resync_all_hooks"}}</td>
44-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="resync_all_hooks">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
44+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="resync_all_hooks">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
4545
</tr>
4646
<tr>
4747
<td>{{ctx.Locale.Tr "admin.dashboard.reinit_missing_repos"}}</td>
48-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="reinit_missing_repos">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
48+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="reinit_missing_repos">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
4949
</tr>
5050
<tr>
5151
<td>{{ctx.Locale.Tr "admin.dashboard.sync_external_users"}}</td>
52-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="sync_external_users">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
52+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="sync_external_users">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
5353
</tr>
5454
<tr>
5555
<td>{{ctx.Locale.Tr "admin.dashboard.repo_health_check"}}</td>
56-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="repo_health_check">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
56+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="repo_health_check">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
5757
</tr>
5858
<tr>
5959
<td>{{ctx.Locale.Tr "admin.dashboard.delete_generated_repository_avatars"}}</td>
60-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="delete_generated_repository_avatars">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
60+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="delete_generated_repository_avatars">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
6161
</tr>
6262
<tr>
6363
<td>{{ctx.Locale.Tr "admin.dashboard.sync_repo_branches"}}</td>
64-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="sync_repo_branches">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
64+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="sync_repo_branches">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
6565
</tr>
6666
<tr>
6767
<td>{{ctx.Locale.Tr "admin.dashboard.sync_repo_tags"}}</td>
68-
<td class="text right"><button type="submit" class="ui primary button" name="op" value="sync_repo_tags">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
68+
<td class="tw-text-right"><button type="submit" class="ui primary button" name="op" value="sync_repo_tags">{{svg "octicon-play"}} {{ctx.Locale.Tr "admin.dashboard.operation_run"}}</button></td>
6969
</tr>
7070
</tbody>
7171
</table>

templates/devtest/fomantic-modal.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
</form>
5050
</div>
5151

52+
<div id="test-modal-form-5" class="ui mini modal">
53+
<div class="header">Form dialog (layout 5)</div>
54+
<div class="content">
55+
<form method="post">
56+
<div class="ui input tw-w-full"><input name="user_input"></div>
57+
{{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}}
58+
</form>
59+
</div>
60+
</div>
61+
5262
<div class="ui g-modal-confirm modal" id="test-modal-default">
5363
<div class="header">{{svg "octicon-file"}} Default dialog <span>title</span></div>
5464
<div class="content">

0 commit comments

Comments
 (0)