Skip to content

Commit 61d668a

Browse files
authored
Merge branch 'main' into fix-clean-path
2 parents 8525289 + a797b84 commit 61d668a

File tree

460 files changed

+2373
-9038
lines changed

Some content is hidden

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

460 files changed

+2373
-9038
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ steps:
726726

727727
# TODO: We should probably build all dependencies into a test image
728728
- name: test-e2e
729-
image: mcr.microsoft.com/playwright:v1.29.2-focal
729+
image: mcr.microsoft.com/playwright:v1.31.2-focal
730730
commands:
731731
- curl -sLO https://go.dev/dl/go1.20.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz
732732
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ fund=false
33
update-notifier=false
44
package-lock=true
55
save-exact=true
6+
lockfile-version=3

CHANGELOG.md

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fmt:
273273

274274
.PHONY: fmt-check
275275
fmt-check: fmt
276-
@diff=$$(git diff $(GO_SOURCES) templates $(WEB_DIRS)); \
276+
@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
277277
if [ -n "$$diff" ]; then \
278278
echo "Please run 'make fmt' and commit the result:"; \
279279
echo "$${diff}"; \
@@ -309,7 +309,7 @@ $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
309309

310310
.PHONY: swagger-check
311311
swagger-check: generate-swagger
312-
@diff=$$(git diff '$(SWAGGER_SPEC)'); \
312+
@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
313313
if [ -n "$$diff" ]; then \
314314
echo "Please run 'make generate-swagger' and commit the result:"; \
315315
echo "$${diff}"; \
@@ -414,7 +414,7 @@ vendor: go.mod go.sum
414414

415415
.PHONY: tidy-check
416416
tidy-check: tidy
417-
@diff=$$(git diff go.mod go.sum $(GO_LICENSE_FILE)); \
417+
@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
418418
if [ -n "$$diff" ]; then \
419419
echo "Please run 'make tidy' and commit the result:"; \
420420
echo "$${diff}"; \
@@ -885,7 +885,7 @@ svg: node-check | node_modules
885885
.PHONY: svg-check
886886
svg-check: svg
887887
@git add $(SVG_DEST_DIR)
888-
@diff=$$(git diff --cached $(SVG_DEST_DIR)); \
888+
@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
889889
if [ -n "$$diff" ]; then \
890890
echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
891891
echo "$${diff}"; \
@@ -895,7 +895,7 @@ svg-check: svg
895895
.PHONY: lockfile-check
896896
lockfile-check:
897897
npm install --package-lock-only
898-
@diff=$$(git diff package-lock.json); \
898+
@diff=$$(git diff --color=always package-lock.json); \
899899
if [ -n "$$diff" ]; then \
900900
echo "package-lock.json is inconsistent with package.json"; \
901901
echo "Please run 'npm install --package-lock-only' and commit the result:"; \

assets/go-licenses.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/generate-svg.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ async function processFile(file, {prefix, fullName} = {}) {
2525
if (prefix === 'octicon') name = name.replace(/-[0-9]+$/, ''); // chop of '-16' on octicons
2626
}
2727

28+
// Set the `xmlns` attribute so that the files are displayable in standalone documents
29+
// The svg backend module will strip the attribute during startup for inline display
2830
const {data} = optimize(await readFile(file, 'utf8'), {
2931
plugins: [
3032
{name: 'preset-default'},
31-
{name: 'removeXMLNS'},
3233
{name: 'removeDimensions'},
3334
{name: 'prefixIds', params: {prefix: () => name}},
3435
{name: 'addClassesToSVGElement', params: {classNames: ['svg', name]}},
35-
{name: 'addAttributesToSVGElement', params: {attributes: [{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}]}},
36+
{
37+
name: 'addAttributesToSVGElement', params: {
38+
attributes: [
39+
{'xmlns': 'http://www.w3.org/2000/svg'},
40+
{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'},
41+
]
42+
}
43+
},
3644
],
3745
});
3846

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ ROUTER = console
18481848
;ENABLED = true
18491849
;;
18501850
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
1851-
;ALLOWED_TYPES = .csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip
1851+
;ALLOWED_TYPES = .csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip
18521852
;;
18531853
;; Max size of each file. Defaults to 4MB
18541854
;MAX_SIZE = 4

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ Default templates for project boards:
841841
## Issue and pull request attachments (`attachment`)
842842

843843
- `ENABLED`: **true**: Whether issue and pull request attachments are enabled.
844-
- `ALLOWED_TYPES`: **.csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
844+
- `ALLOWED_TYPES`: **.csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
845845
- `MAX_SIZE`: **4**: Maximum size (MB).
846846
- `MAX_FILES`: **5**: Maximum number of attachments that can be uploaded at once.
847847
- `STORAGE_TYPE`: **local**: Storage type for attachments, `local` for local disk or `minio` for s3 compatible object storage service, default is `local` or other name defined with `[storage.xxx]`

go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ require (
7878
github.com/minio/minio-go/v7 v7.0.49
7979
github.com/minio/sha256-simd v1.0.0
8080
github.com/msteinert/pam v1.1.0
81-
github.com/nektos/act v0.0.0
81+
github.com/nektos/act v0.2.43
8282
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
8383
github.com/niklasfasching/go-org v1.6.5
8484
github.com/oliamb/cutter v0.2.2
@@ -106,7 +106,7 @@ require (
106106
golang.org/x/crypto v0.6.0
107107
golang.org/x/net v0.7.0
108108
golang.org/x/oauth2 v0.5.0
109-
golang.org/x/sys v0.5.0
109+
golang.org/x/sys v0.6.0
110110
golang.org/x/text v0.7.0
111111
golang.org/x/tools v0.6.0
112112
google.golang.org/grpc v1.53.0
@@ -174,7 +174,6 @@ require (
174174
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
175175
github.com/go-enry/go-oniguruma v1.2.1 // indirect
176176
github.com/go-git/gcfg v1.5.0 // indirect
177-
github.com/go-ini/ini v1.67.0 // indirect
178177
github.com/go-openapi/analysis v0.21.4 // indirect
179178
github.com/go-openapi/errors v0.20.3 // indirect
180179
github.com/go-openapi/inflect v0.19.0 // indirect
@@ -240,7 +239,7 @@ require (
240239
github.com/prometheus/client_model v0.3.0 // indirect
241240
github.com/prometheus/common v0.37.0 // indirect
242241
github.com/prometheus/procfs v0.8.0 // indirect
243-
github.com/rhysd/actionlint v1.6.22 // indirect
242+
github.com/rhysd/actionlint v1.6.23 // indirect
244243
github.com/rivo/uniseg v0.4.4 // indirect
245244
github.com/robfig/cron v1.2.0 // indirect
246245
github.com/rogpeppe/go-internal v1.9.0 // indirect
@@ -287,7 +286,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
287286

288287
replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix
289288

290-
replace github.com/nektos/act => gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744
289+
replace github.com/nektos/act => gitea.com/gitea/act v0.243.1
291290

292291
exclude github.com/gofrs/uuid v3.2.0+incompatible
293292

go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi
5252
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
5353
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
5454
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
55-
gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744 h1:cqzKmGlX0wynSXO04NILpL25eBGwogDrKpkkbwmIpj4=
56-
gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744/go.mod h1:2C/WbTalu1VPNgbVaZJaZDzlOtAKqkXJhdOClxkMy14=
55+
gitea.com/gitea/act v0.243.1 h1:zIVlhGOLE4SHFPW++u3+5Y/jX5mub3QIhB13oNf6rtA=
56+
gitea.com/gitea/act v0.243.1/go.mod h1:iLHCXqOPUElA2nSyHo4wtxSmvdkym3WU7CkP3AxF39Q=
5757
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4=
5858
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
5959
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=
@@ -385,8 +385,6 @@ github.com/go-git/go-git/v5 v5.5.2/go.mod h1:BE5hUJ5yaV2YMxhmaP4l6RBQ08kMxKSPD4B
385385
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
386386
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
387387
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
388-
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
389-
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
390388
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
391389
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
392390
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
@@ -741,7 +739,7 @@ github.com/jhillyerd/enmime v0.10.1 h1:3VP8gFhK7R948YJBrna5bOgnTXEuPAoICo79kKkBK
741739
github.com/jhillyerd/enmime v0.10.1/go.mod h1:Qpe8EEemJMFAF8+NZoWdpXvK2Yb9dRF0k/z6mkcDHsA=
742740
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
743741
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
744-
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
742+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
745743
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
746744
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
747745
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
@@ -1046,8 +1044,8 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
10461044
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
10471045
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
10481046
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
1049-
github.com/rhysd/actionlint v1.6.22 h1:cAEf2PGNwJXhdcTVF2xS/0ORqWS+ueUHwjQYsqFsGSk=
1050-
github.com/rhysd/actionlint v1.6.22/go.mod h1:gIKOdxtV40mBOcD0ZR8EBa8NqjEXToAZioroS3oedMg=
1047+
github.com/rhysd/actionlint v1.6.23 h1:041VOXgZddfvSJa9Il+WT3Iwuo/j0Nmu4bhpAScrds4=
1048+
github.com/rhysd/actionlint v1.6.23/go.mod h1:o5qc1K3I9taGMBhL7mVkpRd64hx3YqI+3t8ewGfYXfE=
10511049
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
10521050
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
10531051
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
@@ -1504,14 +1502,14 @@ golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBc
15041502
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15051503
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15061504
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1507-
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
1508-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1505+
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
1506+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15091507
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
15101508
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
15111509
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
15121510
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
15131511
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
1514-
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
1512+
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
15151513
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
15161514
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
15171515
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

models/actions/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type ActionRunner struct {
2525
ID int64
2626
UUID string `xorm:"CHAR(36) UNIQUE"`
2727
Name string `xorm:"VARCHAR(255)"`
28+
Version string `xorm:"VARCHAR(64)"`
2829
OwnerID int64 `xorm:"index"` // org level runner, 0 means system
2930
Owner *user_model.User `xorm:"-"`
3031
RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global

models/migrations/migrations.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ var migrations = []Migration{
471471
NewMigration("Rename Webhook org_id to owner_id", v1_20.RenameWebhookOrgToOwner),
472472
// v246 -> v247
473473
NewMigration("Add missed column owner_id for project table", v1_20.AddNewColumnForProject),
474+
// v247 -> v248
475+
NewMigration("Fix incorrect project type", v1_20.FixIncorrectProjectType),
476+
// v248 -> v249
477+
NewMigration("Add version column to action_runner table", v1_20.AddVersionToActionRunner),
474478
}
475479

476480
// GetCurrentDBVersion returns the current db version

models/migrations/v1_20/v247.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_20 //nolint
5+
6+
import (
7+
"code.gitea.io/gitea/modules/log"
8+
9+
"xorm.io/xorm"
10+
)
11+
12+
// FixIncorrectProjectType: set individual project's type from 3(TypeOrganization) to 1(TypeIndividual)
13+
func FixIncorrectProjectType(x *xorm.Engine) error {
14+
type User struct {
15+
ID int64 `xorm:"pk autoincr"`
16+
Type int
17+
}
18+
19+
const (
20+
UserTypeIndividual int = 0
21+
22+
TypeIndividual uint8 = 1
23+
TypeOrganization uint8 = 3
24+
)
25+
26+
type Project struct {
27+
OwnerID int64 `xorm:"INDEX"`
28+
Type uint8
29+
Owner *User `xorm:"extends"`
30+
}
31+
32+
sess := x.NewSession()
33+
defer sess.Close()
34+
35+
if err := sess.Begin(); err != nil {
36+
return err
37+
}
38+
39+
count, err := sess.Table("project").
40+
Where("type = ? AND owner_id IN (SELECT id FROM `user` WHERE type = ?)", TypeOrganization, UserTypeIndividual).
41+
Update(&Project{
42+
Type: TypeIndividual,
43+
})
44+
if err != nil {
45+
return err
46+
}
47+
log.Debug("Updated %d projects to belong to a user instead of an organization", count)
48+
49+
return sess.Commit()
50+
}

models/migrations/v1_20/v248.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_20 //nolint
5+
6+
import "xorm.io/xorm"
7+
8+
func AddVersionToActionRunner(x *xorm.Engine) error {
9+
type ActionRunner struct {
10+
Version string `xorm:"VARCHAR(64)"` // the version of act_runner
11+
}
12+
13+
return x.Sync(new(ActionRunner))
14+
}

models/project/project.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,21 @@ func (p *Project) Link() string {
144144
return ""
145145
}
146146

147+
func (p *Project) IconName() string {
148+
if p.IsRepositoryProject() {
149+
return "octicon-project"
150+
}
151+
return "octicon-project-symlink"
152+
}
153+
147154
func (p *Project) IsOrganizationProject() bool {
148155
return p.Type == TypeOrganization
149156
}
150157

158+
func (p *Project) IsRepositoryProject() bool {
159+
return p.Type == TypeRepository
160+
}
161+
151162
func init() {
152163
db.RegisterModel(new(Project))
153164
}
@@ -172,7 +183,7 @@ func GetCardConfig() []CardConfig {
172183
// IsTypeValid checks if a project type is valid
173184
func IsTypeValid(p Type) bool {
174185
switch p {
175-
case TypeRepository, TypeOrganization:
186+
case TypeIndividual, TypeRepository, TypeOrganization:
176187
return true
177188
default:
178189
return false

models/project/project_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestIsProjectTypeValid(t *testing.T) {
2020
typ Type
2121
valid bool
2222
}{
23-
{TypeIndividual, false},
23+
{TypeIndividual, true},
2424
{TypeRepository, true},
2525
{TypeOrganization, true},
2626
{UnknownType, false},

models/repo/release.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,28 @@ func GetReleasesByRepoID(ctx context.Context, repoID int64, opts FindReleasesOpt
253253
return rels, sess.Find(&rels)
254254
}
255255

256+
// GetTagNamesByRepoID returns a list of release tag names of repository.
257+
func GetTagNamesByRepoID(ctx context.Context, repoID int64) ([]string, error) {
258+
listOptions := db.ListOptions{
259+
ListAll: true,
260+
}
261+
opts := FindReleasesOptions{
262+
ListOptions: listOptions,
263+
IncludeDrafts: true,
264+
IncludeTags: true,
265+
HasSha1: util.OptionalBoolTrue,
266+
}
267+
268+
tags := make([]string, 0)
269+
sess := db.GetEngine(ctx).
270+
Table("release").
271+
Desc("created_unix", "id").
272+
Where(opts.toConds(repoID)).
273+
Cols("tag_name")
274+
275+
return tags, sess.Find(&tags)
276+
}
277+
256278
// CountReleasesByRepoID returns a number of releases matching FindReleaseOptions and RepoID.
257279
func CountReleasesByRepoID(repoID int64, opts FindReleasesOptions) (int64, error) {
258280
return db.GetEngine(db.DefaultContext).Where(opts.toConds(repoID)).Count(new(Release))

0 commit comments

Comments
 (0)