Skip to content

Commit 0573139

Browse files
authored
Merge branch 'main' into fix-default-branch-label
2 parents eba9bd1 + 0989f43 commit 0573139

Some content is hidden

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

82 files changed

+1403
-373
lines changed

.github/actionlint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
self-hosted-runner:
2+
labels:
3+
- actuated-4cpu-8gb
4+
- actuated-4cpu-16gb

.github/labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ kind/build:
1919

2020
theme/package-registry:
2121
- "modules/packages/**"
22+
- "services/packages/**"
23+
- "routers/api/packages/**"
24+
- "routers/web/shared/packages/**"
2225

2326
kind/cli:
2427
- "cmd/**"

.github/workflows/release-nightly.yml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ on:
44
push:
55
branches: [ main, release/v* ]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
711
jobs:
812
nightly-binary:
9-
runs-on: ubuntu-latest
13+
runs-on: actuated-4cpu-8gb
1014
steps:
1115
- uses: actions/checkout@v3
1216
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -51,13 +55,17 @@ jobs:
5155
AWS_REGION: ${{ secrets.AWS_REGION }}
5256
SOURCE_DIR: dist/release
5357
DEST_DIR: gitea/${{ steps.clean_name.outputs.branch }}
54-
nightly-docker:
55-
runs-on: ubuntu-latest
58+
nightly-docker-rootful:
59+
runs-on: actuated-4cpu-16gb
5660
steps:
5761
- uses: actions/checkout@v3
5862
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
5963
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
6064
- run: git fetch --unshallow --quiet --tags --force
65+
- uses: actions/setup-go@v4
66+
with:
67+
go-version: "~1.21"
68+
check-latest: true
6169
- uses: docker/setup-qemu-action@v2
6270
- uses: docker/setup-buildx-action@v2
6371
- name: Get cleaned branch name
@@ -75,13 +83,45 @@ jobs:
7583
with:
7684
username: ${{ secrets.DOCKERHUB_USERNAME }}
7785
password: ${{ secrets.DOCKERHUB_TOKEN }}
86+
- name: fetch go modules
87+
run: make vendor
7888
- name: build rootful docker image
7989
uses: docker/build-push-action@v4
8090
with:
8191
context: .
8292
platforms: linux/amd64,linux/arm64
8393
push: true
8494
tags: gitea/gitea:${{ steps.clean_name.outputs.branch }}
95+
nightly-docker-rootless:
96+
runs-on: actuated-4cpu-8gb
97+
steps:
98+
- uses: actions/checkout@v3
99+
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
100+
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
101+
- run: git fetch --unshallow --quiet --tags --force
102+
- uses: actions/setup-go@v4
103+
with:
104+
go-version: "~1.21"
105+
check-latest: true
106+
- uses: docker/setup-qemu-action@v2
107+
- uses: docker/setup-buildx-action@v2
108+
- name: Get cleaned branch name
109+
id: clean_name
110+
run: |
111+
# if main then say nightly otherwise cleanup name
112+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
113+
echo "branch=nightly" >> "$GITHUB_OUTPUT"
114+
exit 0
115+
fi
116+
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//')
117+
echo "branch=${REF_NAME}-nightly" >> "$GITHUB_OUTPUT"
118+
- name: Login to Docker Hub
119+
uses: docker/login-action@v2
120+
with:
121+
username: ${{ secrets.DOCKERHUB_USERNAME }}
122+
password: ${{ secrets.DOCKERHUB_TOKEN }}
123+
- name: fetch go modules
124+
run: make vendor
85125
- name: build rootless docker image
86126
uses: docker/build-push-action@v4
87127
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ cpu.out
9595
/.go-licenses
9696

9797
# Snapcraft
98+
/gitea_a*.txt
9899
snap/.snapcraft/
99100
parts/
100101
stage/

docs/content/usage/packages/cargo.en-us.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ Add the following text to the configuration file located in the current users ho
5050
default = "gitea"
5151
5252
[registries.gitea]
53-
index = "https://gitea.example.com/{owner}/_cargo-index.git"
53+
index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index
54+
# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git
5455
55-
[net]
56-
git-fetch-with-cli = true
56+
# [net]
57+
# git-fetch-with-cli = true
5758
```
5859

5960
| Parameter | Description |
@@ -72,6 +73,12 @@ token = "Bearer {token}"
7273
| --------- | ----------- |
7374
| `token` | Your [personal access token](development/api-usage.md#authentication) |
7475

76+
## Git vs Sparse
77+
78+
Currently, cargo supports two ways for fetching crates in a registry: Git index & sparse index.
79+
Sparse index is the newest method and offers better performance when updating crates compared to git.
80+
Since Rust 1.68, sparse is the default method for crates.io.
81+
7582
## Publish a package
7683

7784
Publish a package by running the following command in your project:

docs/content/usage/packages/cargo.zh-cn.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Cargo 将可用软件包的信息存储在一个存储在 git 仓库中的软件
5050
default = "gitea"
5151
5252
[registries.gitea]
53-
index = "https://gitea.example.com/{owner}/_cargo-index.git"
53+
index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index
54+
# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git
5455
5556
[net]
5657
git-fetch-with-cli = true

models/actions/runner.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ func (opts FindRunnerOptions) toOrder() string {
189189
return "last_online ASC"
190190
case "alphabetically":
191191
return "name ASC"
192+
case "reversealphabetically":
193+
return "name DESC"
194+
case "newest":
195+
return "id DESC"
196+
case "oldest":
197+
return "id ASC"
192198
}
193199
return "last_online DESC"
194200
}

models/repo/git.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
package repo
55

6-
import "code.gitea.io/gitea/models/db"
6+
import (
7+
"code.gitea.io/gitea/models/db"
8+
)
79

810
// MergeStyle represents the approach to merge commits into base branch.
911
type MergeStyle string

modules/indexer/code/git.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ func getRepoChanges(ctx context.Context, repo *repo_model.Repository, revision s
3030
return nil, err
3131
}
3232

33-
if len(status.CommitSha) == 0 {
33+
needGenesis := len(status.CommitSha) == 0
34+
if !needGenesis {
35+
hasAncestorCmd := git.NewCommand(ctx, "merge-base").AddDynamicArguments(repo.CodeIndexerStatus.CommitSha, revision)
36+
stdout, _, _ := hasAncestorCmd.RunStdString(&git.RunOpts{Dir: repo.RepoPath()})
37+
needGenesis = len(stdout) == 0
38+
}
39+
40+
if needGenesis {
3441
return genesisChanges(ctx, repo, revision)
3542
}
3643
return nonGenesisChanges(ctx, repo, revision)

modules/markup/orgmode/orgmode.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,31 @@ func (r *Writer) WriteRegularLink(l org.RegularLink) {
153153
link = []byte(util.URLJoin(r.URLPrefix, lnk))
154154
}
155155

156-
description := string(link)
157-
if l.Description != nil {
158-
description = r.WriteNodesAsString(l.Description...)
159-
}
156+
// Inspired by https://github.com/niklasfasching/go-org/blob/6eb20dbda93cb88c3503f7508dc78cbbc639378f/org/html_writer.go#L406-L427
160157
switch l.Kind() {
161158
case "image":
162-
imageSrc := getMediaURL(link)
163-
fmt.Fprintf(r, `<img src="%s" alt="%s" title="%s" />`, imageSrc, description, description)
159+
if l.Description == nil {
160+
imageSrc := getMediaURL(link)
161+
fmt.Fprintf(r, `<img src="%s" alt="%s" title="%s" />`, imageSrc, link, link)
162+
} else {
163+
description := strings.TrimPrefix(org.String(l.Description...), "file:")
164+
imageSrc := getMediaURL([]byte(description))
165+
fmt.Fprintf(r, `<a href="%s"><img src="%s" alt="%s" /></a>`, link, imageSrc, imageSrc)
166+
}
164167
case "video":
165-
videoSrc := getMediaURL(link)
166-
fmt.Fprintf(r, `<video src="%s" title="%s">%s</video>`, videoSrc, description, description)
168+
if l.Description == nil {
169+
imageSrc := getMediaURL(link)
170+
fmt.Fprintf(r, `<video src="%s" title="%s">%s</video>`, imageSrc, link, link)
171+
} else {
172+
description := strings.TrimPrefix(org.String(l.Description...), "file:")
173+
videoSrc := getMediaURL([]byte(description))
174+
fmt.Fprintf(r, `<a href="%s"><video src="%s" title="%s"></video></a>`, link, videoSrc, videoSrc)
175+
}
167176
default:
177+
description := string(link)
178+
if l.Description != nil {
179+
description = r.WriteNodesAsString(l.Description...)
180+
}
168181
fmt.Fprintf(r, `<a href="%s" title="%s">%s</a>`, link, description, description)
169182
}
170183
}

0 commit comments

Comments
 (0)