Skip to content

Commit 19a0e6c

Browse files
authored
Merge branch 'go-gitea:main' into member-invite
2 parents e89eec1 + b36e2ca commit 19a0e6c

File tree

23 files changed

+308
-104
lines changed

23 files changed

+308
-104
lines changed

Dockerfile

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Build stage
1+
# Build stage
22
FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
33

44
ARG GOPROXY
@@ -9,20 +9,38 @@ ARG TAGS="sqlite sqlite_unlock_notify"
99
ENV TAGS "bindata timetzdata $TAGS"
1010
ARG CGO_EXTRA_CFLAGS
1111

12-
#Build deps
13-
RUN apk --no-cache add build-base git nodejs npm
12+
# Build deps
13+
RUN apk --no-cache add \
14+
build-base \
15+
git \
16+
nodejs \
17+
npm \
18+
&& rm -rf /var/cache/apk/*
1419

15-
#Setup repo
20+
# Setup repo
1621
COPY . ${GOPATH}/src/code.gitea.io/gitea
1722
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
1823

19-
#Checkout version if set
24+
# Checkout version if set
2025
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2126
&& make clean-all build
2227

2328
# Begin env-to-ini build
2429
RUN go build contrib/environment-to-ini/environment-to-ini.go
2530

31+
# Copy local files
32+
COPY docker/root /tmp/local
33+
34+
# Set permissions
35+
RUN chmod 755 /tmp/local/usr/bin/entrypoint \
36+
/tmp/local/usr/local/bin/gitea \
37+
/tmp/local/etc/s6/gitea/* \
38+
/tmp/local/etc/s6/openssh/* \
39+
/tmp/local/etc/s6/.s6-svscan/* \
40+
/go/src/code.gitea.io/gitea/gitea \
41+
/go/src/code.gitea.io/gitea/environment-to-ini
42+
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
43+
2644
FROM docker.io/library/alpine:3.18
2745
LABEL maintainer="maintainers@gitea.io"
2846

@@ -39,7 +57,8 @@ RUN apk --no-cache add \
3957
s6 \
4058
sqlite \
4159
su-exec \
42-
gnupg
60+
gnupg \
61+
&& rm -rf /var/cache/apk/*
4362

4463
RUN addgroup \
4564
-S -g 1000 \
@@ -61,10 +80,7 @@ VOLUME ["/data"]
6180
ENTRYPOINT ["/usr/bin/entrypoint"]
6281
CMD ["/bin/s6-svscan", "/etc/s6"]
6382

64-
COPY docker/root /
83+
COPY --from=build-env /tmp/local /
6584
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
6685
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
6786
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
68-
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
69-
RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/*
70-
RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh

Dockerfile.rootless

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Build stage
1+
# Build stage
22
FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
33

44
ARG GOPROXY
@@ -10,19 +10,35 @@ ENV TAGS "bindata timetzdata $TAGS"
1010
ARG CGO_EXTRA_CFLAGS
1111

1212
#Build deps
13-
RUN apk --no-cache add build-base git nodejs npm
13+
RUN apk --no-cache add \
14+
build-base \
15+
git \
16+
nodejs \
17+
npm \
18+
&& rm -rf /var/cache/apk/*
1419

15-
#Setup repo
20+
# Setup repo
1621
COPY . ${GOPATH}/src/code.gitea.io/gitea
1722
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
1823

19-
#Checkout version if set
24+
# Checkout version if set
2025
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2126
&& make clean-all build
2227

2328
# Begin env-to-ini build
2429
RUN go build contrib/environment-to-ini/environment-to-ini.go
2530

31+
# Copy local files
32+
COPY docker/rootless /tmp/local
33+
34+
# Set permissions
35+
RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
36+
/tmp/local/usr/local/bin/docker-setup.sh \
37+
/tmp/local/usr/local/bin/gitea \
38+
/go/src/code.gitea.io/gitea/gitea \
39+
/go/src/code.gitea.io/gitea/environment-to-ini
40+
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
41+
2642
FROM docker.io/library/alpine:3.18
2743
LABEL maintainer="maintainers@gitea.io"
2844

@@ -35,7 +51,8 @@ RUN apk --no-cache add \
3551
gettext \
3652
git \
3753
curl \
38-
gnupg
54+
gnupg \
55+
&& rm -rf /var/cache/apk/*
3956

4057
RUN addgroup \
4158
-S -g 1000 \
@@ -51,26 +68,23 @@ RUN addgroup \
5168
RUN mkdir -p /var/lib/gitea /etc/gitea
5269
RUN chown git:git /var/lib/gitea /etc/gitea
5370

54-
COPY docker/rootless /
71+
COPY --from=build-env /tmp/local /
5572
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
5673
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
5774
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
58-
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
59-
RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh
6075

61-
#git:git
76+
# git:git
6277
USER 1000:1000
6378
ENV GITEA_WORK_DIR /var/lib/gitea
6479
ENV GITEA_CUSTOM /var/lib/gitea/custom
6580
ENV GITEA_TEMP /tmp/gitea
6681
ENV TMPDIR /tmp/gitea
6782

68-
#TODO add to docs the ability to define the ini to load (useful to test and revert a config)
83+
# TODO add to docs the ability to define the ini to load (useful to test and revert a config)
6984
ENV GITEA_APP_INI /etc/gitea/app.ini
7085
ENV HOME "/var/lib/gitea/git"
7186
VOLUME ["/var/lib/gitea", "/etc/gitea"]
7287
WORKDIR /var/lib/gitea
7388

7489
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
7590
CMD []
76-

docker/root/usr/bin/entrypoint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ ! -x /bin/sh ]; then
77
fi
88

99
if [ "${USER}" != "git" ]; then
10-
# rename user
10+
# Rename user
1111
sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd
1212
fi
1313

@@ -19,13 +19,13 @@ if [ -z "${USER_UID}" ]; then
1919
USER_UID="`id -u ${USER}`"
2020
fi
2121

22-
## Change GID for USER?
22+
# Change GID for USER?
2323
if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then
2424
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group
2525
sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd
2626
fi
2727

28-
## Change UID for USER?
28+
# Change UID for USER?
2929
if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then
3030
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd
3131
fi

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
1818
github.com/NYTimes/gziphandler v1.1.1
1919
github.com/PuerkitoBio/goquery v1.8.1
20-
github.com/alecthomas/chroma/v2 v2.9.1
20+
github.com/alecthomas/chroma/v2 v2.10.0
2121
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
2222
github.com/blevesearch/bleve/v2 v2.3.10
2323
github.com/bufbuild/connect-go v1.10.0
@@ -121,7 +121,7 @@ require (
121121
mvdan.cc/xurls/v2 v2.5.0
122122
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
123123
xorm.io/builder v0.3.13
124-
xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e
124+
xorm.io/xorm v1.3.4
125125
)
126126

127127
require (

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ
118118
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
119119
github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
120120
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
121-
github.com/alecthomas/chroma/v2 v2.9.1 h1:0O3lTQh9FxazJ4BYE/MOi/vDGuHn7B+6Bu902N2UZvU=
122-
github.com/alecthomas/chroma/v2 v2.9.1/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
121+
github.com/alecthomas/chroma/v2 v2.10.0 h1:T2iQOCCt4pRmRMfL55gTodMtc7cU0y7lc1Jb8/mK/64=
122+
github.com/alecthomas/chroma/v2 v2.10.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
123123
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
124124
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
125125
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
@@ -1648,5 +1648,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:
16481648
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
16491649
xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
16501650
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
1651-
xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e h1:oL+ktEW+iSrCXU6IauJ9csZFATEmawkhsq/MAoHTdwo=
1652-
xorm.io/xorm v1.3.4-0.20231017094142-dbe499091a7e/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=
1651+
xorm.io/xorm v1.3.4 h1:vWFKzR3DhGUDl5b4srhUjhDwjxkZAc4C7BFszpu0swI=
1652+
xorm.io/xorm v1.3.4/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=

models/git/commit_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func GetCommitStatuses(ctx context.Context, repo *repo_model.Repository, sha str
235235

236236
countSession := listCommitStatusesStatement(ctx, repo, sha, opts)
237237
countSession = db.SetSessionPagination(countSession, opts)
238-
maxResults, err := countSession.OrderBy("1").Count(new(CommitStatus))
238+
maxResults, err := countSession.Count(new(CommitStatus))
239239
if err != nil {
240240
log.Error("Count PRs: %v", err)
241241
return nil, maxResults, err

models/packages/container/search.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ func (opts *ImageTagsSearchOptions) configureOrderBy(e db.Engine) {
207207
default:
208208
e.Desc("package_version.created_unix")
209209
}
210+
211+
// Sort by id for stable order with duplicates in the other field
212+
e.Asc("package_version.id")
210213
}
211214

212215
// SearchImageTags gets a sorted list of the tags of an image

models/packages/debian/search.go

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ type PackageSearchOptions struct {
2121
Architecture string
2222
}
2323

24-
// SearchLatestPackages gets the latest packages matching the search options
25-
func SearchLatestPackages(ctx context.Context, opts *PackageSearchOptions) ([]*packages.PackageFileDescriptor, error) {
24+
func (opts *PackageSearchOptions) toCond() builder.Cond {
2625
var cond builder.Cond = builder.Eq{
2726
"package_file.is_lead": true,
2827
"package.type": packages.TypeDebian,
@@ -62,28 +61,40 @@ func SearchLatestPackages(ctx context.Context, opts *PackageSearchOptions) ([]*p
6261
})
6362
}
6463

65-
cond = cond.
66-
And(builder.Expr("pv2.id IS NULL"))
64+
return cond
65+
}
6766

68-
joinCond := builder.
69-
Expr("package_version.package_id = pv2.package_id AND (package_version.created_unix < pv2.created_unix OR (package_version.created_unix = pv2.created_unix AND package_version.id < pv2.id))").
70-
And(builder.Eq{"pv2.is_internal": false})
67+
// ExistPackages tests if there are packages matching the search options
68+
func ExistPackages(ctx context.Context, opts *PackageSearchOptions) (bool, error) {
69+
return db.GetEngine(ctx).
70+
Table("package_file").
71+
Join("INNER", "package_version", "package_version.id = package_file.version_id").
72+
Join("INNER", "package", "package.id = package_version.package_id").
73+
Where(opts.toCond()).
74+
Exist(new(packages.PackageFile))
75+
}
7176

72-
pfs := make([]*packages.PackageFile, 0, 10)
73-
err := db.GetEngine(ctx).
77+
// SearchPackages gets the packages matching the search options
78+
func SearchPackages(ctx context.Context, opts *PackageSearchOptions, iter func(*packages.PackageFileDescriptor)) error {
79+
return db.GetEngine(ctx).
7480
Table("package_file").
7581
Select("package_file.*").
7682
Join("INNER", "package_version", "package_version.id = package_file.version_id").
77-
Join("LEFT", "package_version pv2", joinCond).
7883
Join("INNER", "package", "package.id = package_version.package_id").
79-
Where(cond).
80-
Desc("package_version.created_unix").
81-
Find(&pfs)
82-
if err != nil {
83-
return nil, err
84-
}
84+
Where(opts.toCond()).
85+
Asc("package.lower_name", "package_version.created_unix").
86+
Iterate(new(packages.PackageFile), func(_ int, bean any) error {
87+
pf := bean.(*packages.PackageFile)
88+
89+
pfd, err := packages.GetPackageFileDescriptor(ctx, pf)
90+
if err != nil {
91+
return err
92+
}
8593

86-
return packages.GetPackageFileDescriptors(ctx, pfs)
94+
iter(pfd)
95+
96+
return nil
97+
})
8798
}
8899

89100
// GetDistributions gets all available distributions

models/packages/package_version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ func (opts *PackageSearchOptions) configureOrderBy(e db.Engine) {
278278
default:
279279
e.Desc("package_version.created_unix")
280280
}
281+
282+
// Sort by id for stable order with duplicates in the other field
283+
e.Asc("package_version.id")
281284
}
282285

283286
// SearchVersions gets all versions of packages matching the search options

options/locale/locale_en-US.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,8 +3344,6 @@ alpine.repository.repositories = Repositories
33443344
alpine.repository.architectures = Architectures
33453345
cargo.registry = Setup this registry in the Cargo configuration file (for example <code>~/.cargo/config.toml</code>):
33463346
cargo.install = To install the package using Cargo, run the following command:
3347-
cargo.details.repository_site = Repository Site
3348-
cargo.details.documentation_site = Documentation Site
33493347
chef.registry = Setup this registry in your <code>~/.chef/config.rb</code> file:
33503348
chef.install = To install the package, run the following command:
33513349
composer.registry = Setup this registry in your <code>~/.composer/config.json</code> file:
@@ -3357,8 +3355,6 @@ conan.registry = Setup this registry from the command line:
33573355
conan.install = To install the package using Conan, run the following command:
33583356
conda.registry = Setup this registry as a Conda repository in your <code>.condarc</code> file:
33593357
conda.install = To install the package using Conda, run the following command:
3360-
conda.details.repository_site = Repository Site
3361-
conda.details.documentation_site = Documentation Site
33623358
container.details.type = Image Type
33633359
container.details.platform = Platform
33643360
container.pull = Pull the image from the command line:

0 commit comments

Comments
 (0)