Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Use `strings.Cut` for GIT_PROTOCOL value (go-gitea#20638)
  Fix the admin mailer config display (go-gitea#20633)
  Use correct page size for link header pagination (go-gitea#20546)
  Fix package upload for files >32mb (go-gitea#20622)
  Add info about Wire 2 when Git over SSH (go-gitea#20619)
  Enable Wire 2 for Internal SSH Server (go-gitea#20616)
  • Loading branch information
zjjhot committed Aug 3, 2022
2 parents 93acb7e + 7baa7cb commit 51c8e7a
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 17 deletions.
1 change: 1 addition & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ ROUTER = console
;GC_ARGS =
;;
;; If use git wire protocol version 2 when git version >= 2.18, default is true, set to false when you always want git wire protocol version 1
;; To enable this for Git over SSH when using a OpenSSH server, add `AcceptEnv GIT_PROTOCOL` to your sshd_config file.
;ENABLE_AUTO_GIT_WIRE_PROTOCOL = true
;;
;; Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
Expand Down
3 changes: 2 additions & 1 deletion docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,8 @@ Default templates for project boards:
- `COMMITS_RANGE_SIZE`: **50**: Set the default commits range size
- `BRANCHES_RANGE_SIZE`: **20**: Set the default branches range size
- `GC_ARGS`: **\<empty\>**: Arguments for command `git gc`, e.g. `--aggressive --auto`. See more on http://git-scm.com/docs/git-gc/
- `ENABLE_AUTO_GIT_WIRE_PROTOCOL`: **true**: If use Git wire protocol version 2 when Git version >= 2.18, default is true, set to false when you always want Git wire protocol version 1
- `ENABLE_AUTO_GIT_WIRE_PROTOCOL`: **true**: If use Git wire protocol version 2 when Git version >= 2.18, default is true, set to false when you always want Git wire protocol version 1.
To enable this for Git over SSH when using a OpenSSH server, add `AcceptEnv GIT_PROTOCOL` to your sshd_config file.
- `PULL_REQUEST_PUSH_MESSAGE`: **true**: Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
Expand Down
47 changes: 47 additions & 0 deletions modules/packages/hashed_buffer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package packages

import (
"fmt"
"io"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestHashedBuffer(t *testing.T) {
cases := []struct {
MaxMemorySize int
Data string
HashMD5 string
HashSHA1 string
HashSHA256 string
HashSHA512 string
}{
{5, "test", "098f6bcd4621d373cade4e832627b4f6", "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"},
{5, "testtest", "05a671c66aefea124cc08b76ea6d30bb", "51abb9636078defbf888d8457a7c76f85c8f114c", "37268335dd6931045bdcdf92623ff819a64244b53d0e746d438797349d4da578", "125d6d03b32c84d492747f79cf0bf6e179d287f341384eb5d6d3197525ad6be8e6df0116032935698f99a09e265073d1d6c32c274591bf1d0a20ad67cba921bc"},
}

for _, c := range cases {
buf, err := CreateHashedBufferFromReader(strings.NewReader(c.Data), c.MaxMemorySize)
assert.NoError(t, err)

assert.EqualValues(t, len(c.Data), buf.Size())

data, err := io.ReadAll(buf)
assert.NoError(t, err)
assert.Equal(t, c.Data, string(data))

hashMD5, hashSHA1, hashSHA256, hashSHA512 := buf.Sums()
assert.Equal(t, c.HashMD5, fmt.Sprintf("%x", hashMD5))
assert.Equal(t, c.HashSHA1, fmt.Sprintf("%x", hashSHA1))
assert.Equal(t, c.HashSHA256, fmt.Sprintf("%x", hashSHA256))
assert.Equal(t, c.HashSHA512, fmt.Sprintf("%x", hashSHA512))

assert.NoError(t, buf.Close())
}
}
9 changes: 9 additions & 0 deletions modules/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,20 @@ func sessionHandler(session ssh.Session) {
ctx, cancel := context.WithCancel(session.Context())
defer cancel()

gitProtocol := ""
for _, env := range session.Environ() {
if strings.HasPrefix(env, "GIT_PROTOCOL=") {
_, gitProtocol, _ = strings.Cut(env, "=")
break
}
}

cmd := exec.CommandContext(ctx, setting.AppPath, args...)
cmd.Env = append(
os.Environ(),
"SSH_ORIGINAL_COMMAND="+command,
"SKIP_MINWINSVC=1",
"GIT_PROTOCOL="+gitProtocol,
)

stdout, err := cmd.StdoutPipe()
Expand Down
20 changes: 15 additions & 5 deletions modules/util/filebuffer/file_backed_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,45 @@ func (b *FileBackedBuffer) Size() int64 {
return b.size
}

func (b *FileBackedBuffer) switchToReader() {
func (b *FileBackedBuffer) switchToReader() error {
if b.reader != nil {
return
return nil
}

if b.file != nil {
if _, err := b.file.Seek(0, io.SeekStart); err != nil {
return err
}
b.reader = b.file
} else {
b.reader = bytes.NewReader(b.buffer.Bytes())
}
return nil
}

// Read implements io.Reader
func (b *FileBackedBuffer) Read(p []byte) (int, error) {
b.switchToReader()
if err := b.switchToReader(); err != nil {
return 0, err
}

return b.reader.Read(p)
}

// ReadAt implements io.ReaderAt
func (b *FileBackedBuffer) ReadAt(p []byte, off int64) (int, error) {
b.switchToReader()
if err := b.switchToReader(); err != nil {
return 0, err
}

return b.reader.ReadAt(p, off)
}

// Seek implements io.Seeker
func (b *FileBackedBuffer) Seek(offset int64, whence int) (int64, error) {
b.switchToReader()
if err := b.switchToReader(); err != nil {
return 0, err
}

return b.reader.Seek(offset, whence)
}
Expand Down
36 changes: 36 additions & 0 deletions modules/util/filebuffer/file_backed_buffer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package filebuffer

import (
"io"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestFileBackedBuffer(t *testing.T) {
cases := []struct {
MaxMemorySize int
Data string
}{
{5, "test"},
{5, "testtest"},
}

for _, c := range cases {
buf, err := CreateFromReader(strings.NewReader(c.Data), c.MaxMemorySize)
assert.NoError(t, err)

assert.EqualValues(t, len(c.Data), buf.Size())

data, err := io.ReadAll(buf)
assert.NoError(t, err)
assert.Equal(t, c.Data, string(data))

assert.NoError(t, buf.Close())
}
}
9 changes: 6 additions & 3 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2796,16 +2796,19 @@ config.queue_length = Queue Length
config.deliver_timeout = Deliver Timeout
config.skip_tls_verify = Skip TLS Verification

config.mailer_config = SMTP Mailer Configuration
config.mailer_config = Mailer Configuration
config.mailer_enabled = Enabled
config.mailer_disable_helo = Disable HELO
config.mailer_enable_helo = Enable HELO
config.mailer_name = Name
config.mailer_host = Host
config.mailer_protocol = Protocol
config.mailer_smtp_addr = SMTP Addr
config.mailer_smtp_port = SMTP Port
config.mailer_user = User
config.mailer_use_sendmail = Use Sendmail
config.mailer_sendmail_path = Sendmail Path
config.mailer_sendmail_args = Extra Arguments to Sendmail
config.mailer_sendmail_timeout = Sendmail Timeout
config.mailer_use_dummy = Dummy
config.test_email_placeholder = Email (e.g. test@example.com)
config.send_test_mail = Send Testing Email
config.test_mail_failed = Failed to send a testing email to '%s': %v
Expand Down
26 changes: 26 additions & 0 deletions options/locale/locale_nl-NL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1293,11 +1293,13 @@ issues.previous=Vorige
issues.next=Volgende
issues.open_title=Open
issues.closed_title=Gesloten
issues.draft_title=Concept
issues.num_comments=%d opmerkingen
issues.commented_at=`reageerde <a href="#%s">%s</a>`
issues.delete_comment_confirm=Weet u zeker dat u deze reactie wilt verwijderen?
issues.context.copy_link=Link kopiëren
issues.context.quote_reply=Citeer antwoord
issues.context.reference_issue=Verwijs in nieuw issue
issues.context.edit=Bewerken
issues.context.delete=Verwijder
issues.no_content=Er is nog geen inhoud.
Expand All @@ -1323,6 +1325,7 @@ issues.re_request_review=Opnieuw aanvragen review
issues.is_stale=Er zijn wijzigingen aangebracht in deze PR sinds deze beoordeling
issues.remove_request_review=Verwijder beoordelingsverzoek
issues.remove_request_review_block=Kan beoordelingsverzoek niet verwijderen
issues.dismiss_review=Beoordeling afwijzen
issues.sign_in_require_desc=<a href="%s">Log in</a> om deel te nemen aan deze discussie.
issues.edit=Bewerken
issues.cancel=Annuleren
Expand Down Expand Up @@ -1366,13 +1369,21 @@ issues.lock.reason=Reden voor vergrendeling
issues.lock.title=Vergrendel gesprek over dit probleem.
issues.unlock.title=Ontgrendel gesprek over dit probleem.
issues.comment_on_locked=Je kunt geen commentaar geven op een vergrendeld probleem.
issues.delete=Verwijderen
issues.delete.title=Deze issue verwijderen?
issues.delete.text=Wilt u deze issue echt verwijderen? (Dit is permanent en verwijdert alle inhoud. Overweeg om deze issue te sluiten, als u liever deze als archief wilt bijhouden)
issues.tracker=Tijdregistratie
issues.start_tracking_short=Start timer
issues.start_tracking=Start tijdregistratie
issues.start_tracking_history=`%s is begonnen`
issues.tracker_auto_close=Timer wordt automatisch gestopt wanneer dit probleem wordt gesloten
issues.tracking_already_started=`Je houd al tijd bij voor <a href="%s">een ander issue</a>!`
issues.stop_tracking=Stop timer
issues.stop_tracking_history=`gestopt met werken aan %s`
issues.cancel_tracking=Weggooien
issues.cancel_tracking_history=`tijd bijhouden geannuleerd: %s`
issues.add_time=Tijd handmatig toevoegen
issues.del_time=Verwijder deze tijdlog
issues.add_time_short=Timer toevoegen
issues.add_time_cancel=Annuleren
issues.add_time_history=`heeft besteedde tijd toegevoegd: %s`
Expand All @@ -1395,10 +1406,13 @@ issues.due_date_form_remove=Verwijder
issues.due_date_not_writer=Je hebt schrijftoegang in deze repository nodig om de deadline van een kwestie aan te passen.
issues.due_date_not_set=Geen vervaldatum ingesteld.
issues.due_date_added=heeft %[2]s de deadline %[1]s toegevoegd
issues.due_date_modified=de vervaldatum van %[2]s is gewijzigd naar %[1]s[3]s
issues.due_date_remove=heeft %[2]s de deadline %[1]s verwijderd
issues.due_date_overdue=Over tijd
issues.due_date_invalid=De deadline is ongeldig of buiten bereik. Gebruik het formaat 'jjjj-mm-dd'.
issues.dependency.title=Afhankelijkheden
issues.dependency.issue_no_dependencies=Geen afhankelijkheden ingesteld.
issues.dependency.pr_no_dependencies=Geen afhankelijkheden ingesteld.
issues.dependency.add=Voeg afhankelijkheid toe…
issues.dependency.cancel=Annuleer
issues.dependency.remove=Verwijder
Expand Down Expand Up @@ -1579,6 +1593,8 @@ pulls.auto_merge_has_pending_schedule=%[1]s heeft deze pull-verzoek automatisch
pulls.auto_merge_cancel_schedule=Automatisch samenvoegen annuleren
pulls.delete.title=Deze pull-verzoek verwijderen?
pulls.delete.text=Weet je zeker dat je deze pull-verzoek wilt verwijderen? (Dit zal alle inhoud permanent verwijderen. Overweeg om het te sluiten als je het gearchiveerd wilt houden)
milestones.new=Nieuwe mijlpaal
milestones.closed=%s werd gesloten
Expand Down Expand Up @@ -1624,6 +1640,7 @@ signing.wont_sign.commitssigned=De samenvoeging wordt niet ondertekend omdat all
signing.wont_sign.approved=De samenvoeging wordt niet ondertekend omdat de PR niet is goedgekeurd
signing.wont_sign.not_signed_in=U bent niet ingelogd
ext_wiki=Toegang tot Externe Wiki
ext_wiki.desc=Koppelen aan een externe wiki.
wiki=Wiki
Expand All @@ -1648,6 +1665,7 @@ wiki.page_already_exists=Er bestaat al een wiki-pagina met deze naam.
wiki.reserved_page=De wiki-paginanaam '%s' is gereserveerd.
wiki.pages=Pagina’s
wiki.last_updated=Laatst bijgewerkt: %s
wiki.page_name_desc=Voer een naam in voor deze Wiki pagina. Sommige speciale namen zijn: 'Home', '_Sidebar' en '_Footer'.
activity=Activiteit
activity.period.filter_label=Periode:
Expand Down Expand Up @@ -1679,6 +1697,7 @@ activity.closed_issues_count_1=Gesloten problemen
activity.closed_issues_count_n=Gesloten problemen
activity.title.issues_1=%d Probleem
activity.title.issues_n=%d Problemen
activity.title.issues_closed_from=%s gesloten van %s
activity.title.issues_created_by=%s gemaakt door %s
activity.closed_issue_label=Gesloten
activity.new_issues_count_1=Nieuw probleem
Expand Down Expand Up @@ -1716,7 +1735,11 @@ activity.git_stats_deletion_n=%d verwijderingen
search=Zoek
search.search_repo=Zoek repository
search.fuzzy=Vergelijkbaar
search.match=Overeenkomst
search.results=Zoek resultaat voor "%s" in <a href="%s">%s</a>
search.code_no_results=Geen broncode gevonden die aan uw zoekterm voldoet.
search.code_search_unavailable=Er is momenteel geen code zoekfunctie beschikbaar. Neem contact op met uw sitebeheerder.
settings=Instellingen
settings.desc=In de instellingen kan je de instellingen van de repository aanpassen
Expand All @@ -1734,11 +1757,14 @@ settings.mirror_settings=Kopie Settings
settings.mirror_settings.direction=Richting
settings.mirror_settings.direction.pull=Pull
settings.mirror_settings.direction.push=Push
settings.mirror_settings.last_update=Laatst bijgewerkt
settings.mirror_settings.push_mirror.none=Geen spiegels geconfigureerd
settings.mirror_settings.push_mirror.add=Voeg Push Mirror toe
settings.sync_mirror=Synchroniseer
settings.mirror_sync_in_progress=Mirror-synchronisatie is momenteel bezig - kom later terug.
settings.site=Website
settings.update_settings=Instellingen bewerken
settings.branches.update_default_branch=Standaard branch bijwerken
settings.advanced_settings=Geavanceerde opties
settings.wiki_desc=Repository-wiki inschakelen
settings.use_internal_wiki=Ingebouwde wiki gebruiken
Expand Down
Loading

0 comments on commit 51c8e7a

Please sign in to comment.