From dc9cebdf45d3594058727a5c8a5f20af098c5e7a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 21 Feb 2023 14:12:57 +0800 Subject: [PATCH 01/13] Use `--message=%s` for git commit message (#23028) Close #23027 `git commit` message option _only_ supports 4 formats (well, only ....): * `"commit", "-m", msg` * `"commit", "-m{msg}"` (no space) * `"commit", "--message", msg` * `"commit", "--message={msg}"` The long format with `=` is the best choice, and it's documented in `man git-commit`: `-m , --message= ...` ps: I would suggest always use long format option for git command, as much as possible. Co-authored-by: Lunny Xiao --- modules/git/commit.go | 2 +- modules/repository/init.go | 5 ++--- services/pull/merge.go | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/git/commit.go b/modules/git/commit.go index 1f6289ed02224..4a55645d30346 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -131,7 +131,7 @@ func CommitChangesWithArgs(repoPath string, args TrustedCmdArgs, opts CommitChan if opts.Author != nil { cmd.AddOptionFormat("--author='%s <%s>'", opts.Author.Name, opts.Author.Email) } - cmd.AddOptionValues("-m", opts.Message) + cmd.AddOptionFormat("--message=%s", opts.Message) _, _, err := cmd.RunStdString(&RunOpts{Dir: repoPath}) // No stderr but exit status 1 means nothing to commit. diff --git a/modules/repository/init.go b/modules/repository/init.go index 5705fe5b998e4..771b68a4916f8 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -316,9 +316,8 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi return fmt.Errorf("git add --all: %w", err) } - cmd := git.NewCommand(ctx, "commit"). - AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email). - AddOptionValues("-m", "Initial commit") + cmd := git.NewCommand(ctx, "commit", "--message=Initial commit"). + AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email) sign, keyID, signer, _ := asymkey_service.SignInitialCommit(ctx, tmpPath, u) if sign { diff --git a/services/pull/merge.go b/services/pull/merge.go index 3ac67d91b72f1..ad428427cc187 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -533,7 +533,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode if err := git.NewCommand(ctx, "commit"). AddArguments(signArgs...). AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email). - AddOptionValues("-m", message). + AddOptionFormat("--message=%s", message). Run(&git.RunOpts{ Env: env, Dir: tmpBasePath, @@ -641,7 +641,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode func commitAndSignNoAuthor(ctx context.Context, pr *issues_model.PullRequest, message string, signArgs git.TrustedCmdArgs, tmpBasePath string, env []string) error { var outbuf, errbuf strings.Builder - if err := git.NewCommand(ctx, "commit").AddArguments(signArgs...).AddOptionValues("-m", message). + if err := git.NewCommand(ctx, "commit").AddArguments(signArgs...).AddOptionFormat("--message=%s", message). Run(&git.RunOpts{ Env: env, Dir: tmpBasePath, From e7be610d5773e69abbfb98d19e23112dfad6dfcc Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 21 Feb 2023 14:13:37 +0800 Subject: [PATCH 02/13] Improve frontend guidelines (#23007) Some were out-dated, some are added. --- .../developers/guidelines-frontend.en-us.md | 18 +++++++--- web_src/js/features/aria.md | 33 +++++++++++++++++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/docs/content/doc/developers/guidelines-frontend.en-us.md b/docs/content/doc/developers/guidelines-frontend.en-us.md index 23be6c67737af..7f4d87d9011ed 100644 --- a/docs/content/doc/developers/guidelines-frontend.en-us.md +++ b/docs/content/doc/developers/guidelines-frontend.en-us.md @@ -39,12 +39,20 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h ### Gitea specific guidelines: 1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories. -2. HTML ids and classes should use kebab-case. +2. HTML ids and classes should use kebab-case, it's preferred to contain 2-3 feature related keywords. 3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript. -4. jQuery events across different features could use their own namespaces if there are potential conflicts. -5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names with 2-3 feature related keywords to overwrite framework styles. -6. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}` -7. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue3. +4. CSS styling for classes provided by frameworks should not be overwritten. Always use new class names with 2-3 feature related keywords to overwrite framework styles. Gitea's helper CSS classes in `helpers.less` could be helpful. +5. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`, but do not expose whole models to the frontend to avoid leaking sensitive data. +6. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue3. +7. Clarify variable types, prefer `elem.disabled = true` instead of `elem.setAttribute('disabled', 'anything')`, prefer `$el.prop('checked', var === 'yes')` instead of `$el.prop('checked', var)`. +8. Use semantic elements, prefer ` - - -
- -
{{end}} {{if and .ShowMergeInstructions .Issue.PullRequest.HeadRepo}} diff --git a/web_src/js/components/PullRequestMergeForm.vue b/web_src/js/components/PullRequestMergeForm.vue index 2e10ce2531f06..bc960c1e70130 100644 --- a/web_src/js/components/PullRequestMergeForm.vue +++ b/web_src/js/components/PullRequestMergeForm.vue @@ -36,6 +36,10 @@ +
+ +
+