Skip to content

Commit 3313694

Browse files
authored
Merge branch 'main' into fix-20456-prepend-refs-heads
2 parents e3afb9d + fd89c06 commit 3313694

File tree

9 files changed

+36
-41
lines changed

9 files changed

+36
-41
lines changed

docs/content/doc/installation/from-source.fr-fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ git checkout pr-xyz
5353

5454
## Compilation
5555

56-
Comme nous regroupons déjà toutes les bibliothèques requises pour compiler Gitea, vous pouvez continuer avec le processus de compilation lui-même. Nous fournissons diverses [tâches Make](https://github.com/go-gitea/gitea/blob/master/Makefile) pour rendre le processus de construction aussi simple que possible. [Voyez ici comment obtenir Make]({{< relref "doc/developers/hacking-on-gitea.fr-fr.md" >}}#installing-make). Selon vos besoins, vous pourrez éventuellement ajouter diverses options de compilation, vous pouvez choisir entre ces options :
56+
Comme nous regroupons déjà toutes les bibliothèques requises pour compiler Gitea, vous pouvez continuer avec le processus de compilation lui-même. Nous fournissons diverses [tâches Make](https://github.com/go-gitea/gitea/blob/master/Makefile) pour rendre le processus de construction aussi simple que possible. [Voyez ici comment obtenir Make](/fr-fr/hacking-on-gitea/). Selon vos besoins, vous pourrez éventuellement ajouter diverses options de compilation, vous pouvez choisir entre ces options :
5757

5858
* `bindata`: Intègre toutes les ressources nécessaires à l'exécution d'une instance de Gitea, ce qui rend un déploiement facile car il n'est pas nécessaire de se préoccuper des fichiers supplémentaires.
5959
* `sqlite sqlite_unlock_notify`: Active la prise en charge d'une base de données [SQLite3](https://sqlite.org/), ceci n'est recommandé que pour les petites installations de Gitea.

docs/content/doc/installation/from-source.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ git checkout v{{< version >}}
5454

5555
- `go` {{< min-go-version >}} 或以上版本, 详见[这里](https://golang.google.cn/doc/install)
5656
- `node` {{< min-node-version >}} 或以上版本,并且安装 `npm`, 详见[这里](https://nodejs.org/zh-cn/download/)
57-
- `make`, 详见[这里]({{< relref "doc/developers/hacking-on-gitea.zh-cn.md" >}})</a>
57+
- `make`, 详见[这里](/zh-cn/hacking-on-gitea/)
5858

5959
各种可用的 [make 任务](https://github.com/go-gitea/gitea/blob/main/Makefile)
6060
可以用来使编译过程更方便。

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ edit = Edit
8888

8989
copy = Copy
9090
copy_url = Copy URL
91+
copy_content = Copy content
9192
copy_branch = Copy branch name
9293
copy_success = Copied!
9394
copy_error = Copy failed
@@ -1090,6 +1091,7 @@ editor.cannot_edit_non_text_files = Binary files cannot be edited in the web int
10901091
editor.edit_this_file = Edit File
10911092
editor.this_file_locked = File is locked
10921093
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file.
1094+
editor.only_copy_raw = You may only copy raw text files.
10931095
editor.fork_before_edit = You must fork this repository to make or propose changes to this file.
10941096
editor.delete_this_file = Delete File
10951097
editor.must_have_write_access = You must have write access to make or propose changes to this file.

routers/api/packages/pypi/pypi.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ import (
2525
var normalizer = strings.NewReplacer(".", "-", "_", "-")
2626
var nameMatcher = regexp.MustCompile(`\A[a-zA-Z0-9\.\-_]+\z`)
2727

28-
// https://www.python.org/dev/peps/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
29-
var versionMatcher = regexp.MustCompile(`^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$`)
28+
// https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
29+
var versionMatcher = regexp.MustCompile(`\Av?` +
30+
`(?:[0-9]+!)?` + // epoch
31+
`[0-9]+(?:\.[0-9]+)*` + // release segment
32+
`(?:[-_\.]?(?:a|b|c|rc|alpha|beta|pre|preview)[-_\.]?[0-9]*)?` + // pre-release
33+
`(?:-[0-9]+|[-_\.]?(?:post|rev|r)[-_\.]?[0-9]*)?` + // post release
34+
`(?:[-_\.]?dev[-_\.]?[0-9]*)?` + // dev release
35+
`(?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)?` + // local version
36+
`\z`)
3037

3138
func apiError(ctx *context.Context, status int, obj interface{}) {
3239
helper.LogAndProcessError(ctx, status, obj, func(message string) {

routers/web/dev/template.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

routers/web/web.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"code.gitea.io/gitea/modules/web/routing"
2929
"code.gitea.io/gitea/routers/web/admin"
3030
"code.gitea.io/gitea/routers/web/auth"
31-
"code.gitea.io/gitea/routers/web/dev"
3231
"code.gitea.io/gitea/routers/web/events"
3332
"code.gitea.io/gitea/routers/web/explore"
3433
"code.gitea.io/gitea/routers/web/feed"
@@ -619,10 +618,6 @@ func RegisterRoutes(m *web.Route) {
619618

620619
m.Post("/{username}", reqSignIn, context_service.UserAssignmentWeb(), user.Action)
621620

622-
if !setting.IsProd {
623-
m.Get("/template/*", dev.TemplatePreview)
624-
}
625-
626621
reqRepoAdmin := context.RequireRepoAdmin()
627622
reqRepoCodeWriter := context.RequireRepoWriter(unit.TypeCode)
628623
canEnableEditor := context.CanEnableEditor()

templates/repo/view_file.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
{{end}}
6161
</div>
6262
<a download href="{{$.RawFileLink}}"><span class="btn-octicon tooltip" data-content="{{.locale.Tr "repo.download_file"}}" data-position="bottom center">{{svg "octicon-download"}}</span></a>
63+
{{if or .IsMarkup .IsRenderedHTML (not .IsTextSource)}}
64+
<span class="btn-octicon tooltip disabled" id="copy-file-content" data-content="{{.locale.Tr "repo.editor.only_copy_raw"}}" aria-label="{{.locale.Tr "repo.editor.only_copy_raw"}}">{{svg "octicon-copy" 14}}</span>
65+
{{else}}
66+
<a class="btn-octicon tooltip" id="copy-file-content" data-content="{{.locale.Tr "copy_content"}}" aria-label="{{.locale.Tr "copy_content"}}">{{svg "octicon-copy" 14}}</a>
67+
{{end}}
6368
{{if .Repository.CanEnableEditor}}
6469
{{if .CanEditFile}}
6570
<a href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}"><span class="btn-octicon tooltip" data-content="{{.EditFileTooltip}}" data-position="bottom center">{{svg "octicon-pencil"}}</span></a>

tests/integration/api_packages_pypi_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestPackagePyPI(t *testing.T) {
2929
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
3030

3131
packageName := "test-package"
32-
packageVersion := "1.0.1"
32+
packageVersion := "1.0.1+r1234"
3333
packageAuthor := "KN4CK3R"
3434
packageDescription := "Test Description"
3535

@@ -164,7 +164,7 @@ func TestPackagePyPI(t *testing.T) {
164164
nodes := htmlDoc.doc.Find("a").Nodes
165165
assert.Len(t, nodes, 2)
166166

167-
hrefMatcher := regexp.MustCompile(fmt.Sprintf(`%s/files/%s/%s/test\..+#sha256-%s`, root, packageName, packageVersion, hashSHA256))
167+
hrefMatcher := regexp.MustCompile(fmt.Sprintf(`%s/files/%s/%s/test\..+#sha256-%s`, root, regexp.QuoteMeta(packageName), regexp.QuoteMeta(packageVersion), hashSHA256))
168168

169169
for _, a := range nodes {
170170
for _, att := range a.Attr {

web_src/js/features/repo-code.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import $ from 'jquery';
22
import {svg} from '../svg.js';
33
import {invertFileFolding} from './file-fold.js';
4-
import {createTippy} from '../modules/tippy.js';
4+
import {createTippy, showTemporaryTooltip} from '../modules/tippy.js';
55
import {copyToClipboard} from './clipboard.js';
66

7+
const {i18n} = window.config;
8+
79
function changeHash(hash) {
810
if (window.history.pushState) {
911
window.history.pushState(null, null, hash);
@@ -110,6 +112,18 @@ function showLineButton() {
110112
});
111113
}
112114

115+
function initCopyFileContent() {
116+
// get raw text for copy content button, at the moment, only one button (and one related file content) is supported.
117+
const copyFileContent = document.querySelector('#copy-file-content');
118+
if (!copyFileContent) return;
119+
120+
copyFileContent.addEventListener('click', async () => {
121+
const text = Array.from(document.querySelectorAll('.file-view .lines-code')).map((el) => el.textContent).join('');
122+
const success = await copyToClipboard(text);
123+
showTemporaryTooltip(copyFileContent, success ? i18n.copy_success : i18n.copy_error);
124+
});
125+
}
126+
113127
export function initRepoCodeView() {
114128
if ($('.code-view .lines-num').length > 0) {
115129
$(document).on('click', '.lines-num span', function (e) {
@@ -185,4 +199,5 @@ export function initRepoCodeView() {
185199
if (!success) return;
186200
document.querySelector('.code-line-button')?._tippy?.hide();
187201
});
202+
initCopyFileContent();
188203
}

0 commit comments

Comments
 (0)