Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Add link to members and repositories at teams page (go-gitea#27744)
  Add dedicated class for empty placeholders (go-gitea#27788)
  Close all hashed buffers (go-gitea#27787)
  Fix typo when updating email address (go-gitea#27789)
  Improve pull request command line instructions (go-gitea#27778)
  • Loading branch information
zjjhot committed Oct 26, 2023
2 parents 0d4b119 + 4f4ddcf commit 223e394
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 27 deletions.
2 changes: 1 addition & 1 deletion modules/packages/hashed_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewHashedBuffer() (*HashedBuffer, error) {
return NewHashedBufferWithSize(DefaultMemorySize)
}

// NewHashedBuffer creates a hashed buffer with a specific memory size
// NewHashedBufferWithSize creates a hashed buffer with a specific memory size
func NewHashedBufferWithSize(maxMemorySize int) (*HashedBuffer, error) {
b, err := filebuffer.New(maxMemorySize)
if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ write = Write
preview = Preview
loading = Loading…

step1 = Step 1:
step2 = Step 2:

error = Error
error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it.
go_back = Go Back
Expand Down Expand Up @@ -1797,9 +1794,11 @@ pulls.outdated_with_base_branch = This branch is out-of-date with the base branc
pulls.close = Close Pull Request
pulls.closed_at = `closed this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
pulls.reopened_at = `reopened this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
pulls.merge_instruction_hint = `You can also view <a class="show-instruction">command line instructions</a>.`
pulls.merge_instruction_step1_desc = From your project repository, check out a new branch and test the changes.
pulls.merge_instruction_step2_desc = Merge the changes and update on Gitea.
pulls.cmd_instruction_hint = `View <a class="show-instruction">command line instructions</a>.`
pulls.cmd_instruction_checkout_title = Checkout
pulls.cmd_instruction_checkout_desc = From your project repository, check out a new branch and test the changes.
pulls.cmd_instruction_merge_title = Merge
pulls.cmd_instruction_merge_desc = Merge the changes and update on Gitea.
pulls.clear_merge_message = Clear merge message
pulls.clear_merge_message_hint = Clearing the merge message will only remove the commit message content and keep generated git trailers such as "Co-Authored-By …".

Expand Down Expand Up @@ -2857,7 +2856,7 @@ emails.updated = Email updated
emails.not_updated = Failed to update the requested email address: %v
emails.duplicate_active = This email address is already active for a different user.
emails.change_email_header = Update Email Properties
emails.change_email_text = Are your sure you want to update this email address?
emails.change_email_text = Are you sure you want to update this email address?

orgs.org_manage_panel = Organization Management
orgs.name = Name
Expand Down
3 changes: 3 additions & 0 deletions services/packages/alpine/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ func buildPackagesIndex(ctx context.Context, ownerID int64, repoVersion *package
}

unsignedIndexContent, _ := packages_module.NewHashedBuffer()
defer unsignedIndexContent.Close()

h := sha1.New()

if err := writeGzipStream(io.MultiWriter(unsignedIndexContent, h), "APKINDEX", buf.Bytes(), true); err != nil {
Expand Down Expand Up @@ -275,6 +277,7 @@ func buildPackagesIndex(ctx context.Context, ownerID int64, repoVersion *package
}

signedIndexContent, _ := packages_module.NewHashedBuffer()
defer signedIndexContent.Close()

if err := writeGzipStream(
signedIndexContent,
Expand Down
10 changes: 10 additions & 0 deletions services/packages/debian/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,16 @@ func buildPackagesIndices(ctx context.Context, ownerID int64, repoVersion *packa
}

packagesContent, _ := packages_module.NewHashedBuffer()
defer packagesContent.Close()

packagesGzipContent, _ := packages_module.NewHashedBuffer()
defer packagesGzipContent.Close()

gzw := gzip.NewWriter(packagesGzipContent)

packagesXzContent, _ := packages_module.NewHashedBuffer()
defer packagesXzContent.Close()

xzw, _ := xz.NewWriter(packagesXzContent)

w := io.MultiWriter(packagesContent, gzw, xzw)
Expand Down Expand Up @@ -323,6 +328,8 @@ func buildReleaseFiles(ctx context.Context, ownerID int64, repoVersion *packages
}

inReleaseContent, _ := packages_module.NewHashedBuffer()
defer inReleaseContent.Close()

sw, err := clearsign.Encode(inReleaseContent, e.PrivateKey, nil)
if err != nil {
return err
Expand Down Expand Up @@ -367,11 +374,14 @@ func buildReleaseFiles(ctx context.Context, ownerID int64, repoVersion *packages
sw.Close()

releaseGpgContent, _ := packages_module.NewHashedBuffer()
defer releaseGpgContent.Close()

if err := openpgp.ArmoredDetachSign(releaseGpgContent, e, bytes.NewReader(buf.Bytes()), nil); err != nil {
return err
}

releaseContent, _ := packages_module.CreateHashedBufferFromReader(&buf)
defer releaseContent.Close()

for _, file := range []struct {
Name string
Expand Down
5 changes: 5 additions & 0 deletions services/packages/rpm/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,14 @@ func buildRepomd(ctx context.Context, pv *packages_model.PackageVersion, ownerID
}

repomdAscContent, _ := packages_module.NewHashedBuffer()
defer repomdAscContent.Close()

if err := openpgp.ArmoredDetachSign(repomdAscContent, e, bytes.NewReader(buf.Bytes()), nil); err != nil {
return err
}

repomdContent, _ := packages_module.CreateHashedBufferFromReader(&buf)
defer repomdContent.Close()

for _, file := range []struct {
Name string
Expand Down Expand Up @@ -548,6 +551,8 @@ func (wc *writtenCounter) Written() int64 {

func addDataAsFileToRepo(ctx context.Context, pv *packages_model.PackageVersion, filetype string, obj any) (*repoData, error) {
content, _ := packages_module.NewHashedBuffer()
defer content.Close()

gzw := gzip.NewWriter(content)
wc := &writtenCounter{}
h := sha256.New()
Expand Down
2 changes: 1 addition & 1 deletion templates/org/team/teams.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{{end}}
</div>
<div class="ui bottom attached header">
<p class="team-meta">{{.NumMembers}} {{ctx.Locale.Tr "org.lower_members"}} · {{.NumRepos}} {{ctx.Locale.Tr "org.lower_repositories"}}</p>
<p class="team-meta"><a class="muted" href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}">{{.NumMembers}} {{ctx.Locale.Tr "org.lower_members"}}</a> · <a class="muted" href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}/repositories">{{.NumRepos}} {{ctx.Locale.Tr "org.lower_repositories"}}</a></p>
</div>
</div>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/package/shared/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>
{{else}}
{{if not .HasPackages}}
<div class="empty center">
<div class="empty-placeholder">
{{svg "octicon-package" 48}}
<h2>{{ctx.Locale.Tr "packages.empty"}}</h2>
{{if and .Repository .CanWritePackages}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/actions/runs_list.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="flex-list">
{{if eq (len .Runs) 0}}
<div class="empty center">
<div class="empty-placeholder">
{{svg "octicon-no-entry" 48}}
<h2>{{if $.IsFiltered}}{{ctx.Locale.Tr "actions.runs.no_results"}}{{else}}{{ctx.Locale.Tr "actions.runs.no_runs"}}{{end}}</h2>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@
</div>
{{end}}

{{if and .ShowMergeInstructions .Issue.PullRequest.HeadRepo (not .Issue.PullRequest.HasMerged) (not .Issue.IsClosed)}}
{{template "repo/issue/view_content/pull_merge_instruction" .Issue.PullRequest}}
{{if and .Issue.PullRequest.HeadRepo (not .Issue.PullRequest.HasMerged) (not .Issue.IsClosed)}}
{{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "ShowMergeInstructions" .ShowMergeInstructions}}
{{end}}
</div>
</div>
Expand Down
46 changes: 36 additions & 10 deletions templates/repo/issue/view_content/pull_merge_instruction.tmpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
<div class="divider"></div>
<div class="instruct-toggle"> {{ctx.Locale.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
<div class="instruct-toggle"> {{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint" | Safe}} </div>
<div class="instruct-content gt-mt-3 gt-hidden">
<div><h3 class="gt-dib">{{ctx.Locale.Tr "step1"}}</h3> {{ctx.Locale.Tr "repo.pulls.merge_instruction_step1_desc"}}</div>
<div><h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}</h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}}</div>
{{$localBranch := .PullRequest.HeadBranch}}
{{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}
{{$localBranch = print .PullRequest.HeadRepo.OwnerName "-" .PullRequest.HeadBranch}}
{{end}}
<div class="ui secondary segment">
{{if eq .Flow 0}}
<div>git checkout -b {{if ne .HeadRepo.ID .BaseRepo.ID}}{{.HeadRepo.OwnerName}}-{{end}}{{.HeadBranch}} {{.BaseBranch}}</div>
<div>git pull {{if ne .HeadRepo.ID .BaseRepo.ID}}<gitea-origin-url data-url="{{.HeadRepo.Link}}"></gitea-origin-url>{{else}}origin{{end}} {{.HeadBranch}}</div>
{{if eq .PullRequest.Flow 0}}
<div>git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}<gitea-origin-url data-url="{{.PullRequest.HeadRepo.Link}}"></gitea-origin-url>{{else}}origin{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}</div>
<div>git checkout {{$localBranch}}</div>
{{else}}
<div>git fetch origin {{.GetGitRefName}}:{{.HeadBranch}}</div>
<div>git fetch -u origin {{.GetGitRefName}}:{{$localBranch}}</div>
{{end}}
</div>
<div><h3 class="gt-dib">{{ctx.Locale.Tr "step2"}}</h3> {{ctx.Locale.Tr "repo.pulls.merge_instruction_step2_desc"}}</div>
{{if .ShowMergeInstructions}}
<div><h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}</h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}}</div>
<div class="ui secondary segment">
<div>git checkout {{.BaseBranch}}</div>
<div>git merge --no-ff {{if ne .HeadRepo.ID .BaseRepo.ID}}{{.HeadRepo.OwnerName}}-{{end}}{{.HeadBranch}}</div>
<div>git push origin {{.BaseBranch}}</div>
<div data-pull-merge-style="merge">
<div>git checkout {{.PullRequest.BaseBranch}}</div>
<div>git merge --no-ff {{$localBranch}}</div>
</div>
<div class="gt-hidden" data-pull-merge-style="rebase">
<div>git checkout {{.PullRequest.BaseBranch}}</div>
<div>git merge --ff-only {{$localBranch}}</div>
</div>
<div class="gt-hidden" data-pull-merge-style="rebase-merge">
<div>git checkout {{$localBranch}}</div>
<div>git rebase {{.PullRequest.BaseBranch}}</div>
<div>git checkout {{.PullRequest.BaseBranch}}</div>
<div>git merge --no-ff {{$localBranch}}</div>
</div>
<div class="gt-hidden" data-pull-merge-style="squash">
<div>git checkout {{.PullRequest.BaseBranch}}</div>
<div>git merge --squash {{$localBranch}}</div>
</div>
<div class="gt-hidden" data-pull-merge-style="manually-merged">
<div>git checkout {{.PullRequest.BaseBranch}}</div>
<div>git merge {{$localBranch}}</div>
</div>
<div>git push origin {{.PullRequest.BaseBranch}}</div>
</div>
{{end}}
</div>
10 changes: 6 additions & 4 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1798,10 +1798,12 @@
flex: 1
}

.repository.packages .empty,
.repository.actions .empty {
padding-top: 70px;
padding-bottom: 100px;
.empty-placeholder {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
}

.repository.packages .file-size {
Expand Down
4 changes: 4 additions & 0 deletions web_src/js/components/PullRequestMergeForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import {SvgIcon} from '../svg.js';
import {toggleElem} from '../utils/dom.js';
const {csrfToken, pageData} = window.config;
Expand Down Expand Up @@ -39,6 +40,9 @@ export default {
watch: {
mergeStyle(val) {
this.mergeStyleDetail = this.mergeForm.mergeStyles.find((e) => e.name === val);
for (const elem of document.querySelectorAll('[data-pull-merge-style]')) {
toggleElem(elem, elem.getAttribute('data-pull-merge-style') === val);
}
}
},
created() {
Expand Down

0 comments on commit 223e394

Please sign in to comment.