Skip to content

Commit dc29ed2

Browse files
Merge branch 'master' into master
2 parents 4209065 + 013657e commit dc29ed2

Some content is hidden

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

52 files changed

+208
-269
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ steps:
501501
pull: always
502502
image: techknowlogick/xgo:go-1.16.x
503503
commands:
504-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt -y install nodejs bsdtar\|libarchive-tools
504+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
505505
- export PATH=$PATH:$GOPATH/bin
506506
- make release
507507
environment:
@@ -597,7 +597,7 @@ steps:
597597
pull: always
598598
image: techknowlogick/xgo:go-1.16.x
599599
commands:
600-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs bsdtar\|libarchive-tools
600+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
601601
- export PATH=$PATH:$GOPATH/bin
602602
- make release
603603
environment:

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ coverage.all
8181
/public/fonts
8282
/public/img/webpack
8383
/web_src/fomantic/node_modules
84-
/web_src/fomantic/semantic.json
8584
/web_src/fomantic/build/*
8685
!/web_src/fomantic/build/semantic.js
8786
!/web_src/fomantic/build/semantic.css
@@ -95,7 +94,6 @@ coverage.all
9594
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
9695
/VERSION
9796
/.air
98-
/.npm-cache
9997

10098
# Snapcraft
10199
snap/.snapcraft/

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
audit=false
22
fund=false
3+
update-notifier=false
34
package-lock=true
45
save-exact=true
5-
cache=.npm-cache

Makefile

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ else
1414

1515
# This is the "normal" part of the Makefile
1616

17-
TAR := $(shell hash bsdtar > /dev/null 2>&1 && echo "bsdtar --no-xattrs" || echo "tar" )
18-
1917
DIST := dist
2018
DIST_DIRS := $(DIST)/binaries $(DIST)/release
2119
IMPORT := code.gitea.io/gitea
@@ -93,8 +91,6 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
9391

9492
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/models/migrations code.gitea.io/gitea/integrations/migration-test code.gitea.io/gitea/integrations,$(shell $(GO) list -mod=vendor ./... | grep -v /vendor/))
9593

96-
FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
97-
FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
9894
FOMANTIC_WORK_DIR := web_src/fomantic
9995

10096
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
@@ -115,6 +111,8 @@ TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
115111

116112
TEST_TAGS ?= sqlite sqlite_unlock_notify
117113

114+
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR)
115+
118116
GO_DIRS := cmd integrations models modules routers build services vendor tools
119117

120118
GO_SOURCES := $(wildcard *.go)
@@ -589,7 +587,7 @@ install: $(wildcard *.go)
589587
build: frontend backend
590588

591589
.PHONY: frontend
592-
frontend: node-check $(WEBPACK_DEST)
590+
frontend: $(WEBPACK_DEST)
593591

594592
.PHONY: backend
595593
backend: go-check generate $(EXECUTABLE)
@@ -654,16 +652,16 @@ release-compress: | $(DIST_DIRS)
654652
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
655653

656654
.PHONY: release-sources
657-
release-sources: | $(DIST_DIRS) npm-cache
655+
release-sources: | $(DIST_DIRS)
658656
echo $(VERSION) > $(STORED_VERSION_FILE)
659-
$(eval EXCL := --exclude=$(shell [ ! "$(TAR)" = "tar" ] && echo "^" )./)
660-
$(eval EXCL_RECURSIVE := --exclude=)
661-
$(TAR) $(EXCL)$(DIST) $(EXCL).git $(EXCL)$(MAKE_EVIDENCE_DIR) $(EXCL_RECURSIVE)node_modules $(EXCL)$(AIR_TMP_DIR) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
657+
# bsdtar needs a ^ to prevent matching subdirectories
658+
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
659+
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
662660
rm -f $(STORED_VERSION_FILE)
663661

664662
.PHONY: release-docs
665663
release-docs: | $(DIST_DIRS) docs
666-
$(TAR) -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
664+
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
667665

668666
.PHONY: docs
669667
docs:
@@ -676,25 +674,6 @@ node_modules: package-lock.json
676674
npm install --no-save
677675
@touch node_modules
678676

679-
.PHONY: npm-cache
680-
npm-cache: .npm-cache $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
681-
682-
.npm-cache: package-lock.json
683-
rm -rf .npm-cache
684-
$(eval ESBUILD_VERSION := $(shell node -p "require('./package-lock.json').dependencies.esbuild.version"))
685-
npm config --userconfig=.npmrc set cache=.npm-cache
686-
rm -rf node_modules && npm install --no-save
687-
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc set cache=../../.npm-cache
688-
echo $(foreach build, darwin-64 $(foreach arch,arm arm64 32 64,linux-${arch}) $(foreach arch,32 64,windows-${arch}), esbuild-${build}@$(ESBUILD_VERSION)) | tr " " "\n" | xargs -n 1 -P 4 npm cache add
689-
rm -rf $(FOMANTIC_WORK_DIR)/node_modules
690-
@touch .npm-cache
691-
692-
.PHONY: npm-uncache
693-
npm-uncache:
694-
rm -rf .npm-cache
695-
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc rm cache
696-
npm config --userconfig=.npmrc rm cache
697-
698677
.PHONY: npm-update
699678
npm-update: node-check | node_modules
700679
npx updates -cu
@@ -703,30 +682,18 @@ npm-update: node-check | node_modules
703682
@touch node_modules
704683

705684
.PHONY: fomantic
706-
fomantic: $(FOMANTIC_DEST)
707-
708-
$(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui:
709-
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
710-
cd $(FOMANTIC_WORK_DIR); \
711-
rm -rf node_modules && mkdir node_modules && \
712-
npm install fomantic-ui; \
713-
rm -f semantic.json
714-
@touch $(FOMANTIC_WORK_DIR)/node_modules
715-
716-
$(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
717-
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
685+
fomantic:
718686
rm -rf $(FOMANTIC_WORK_DIR)/build
719-
cd $(FOMANTIC_WORK_DIR); \
720-
cp -f theme.config.less node_modules/fomantic-ui/src/theme.config; \
721-
cp -rf _site node_modules/fomantic-ui/src/; \
722-
npx gulp -f node_modules/fomantic-ui/gulpfile.js build; \
723-
rm -f semantic.json
724-
@touch $(FOMANTIC_DEST)
687+
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
688+
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
689+
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
690+
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
725691

726692
.PHONY: webpack
727693
webpack: $(WEBPACK_DEST)
728694

729-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
695+
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
696+
@$(MAKE) -s node-check node_modules
730697
rm -rf $(WEBPACK_DEST_ENTRIES)
731698
npx webpack
732699
@touch $(WEBPACK_DEST)

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ or if sqlite support is required:
7777
The `build` target is split into two sub-targets:
7878

7979
- `make backend` which requires [Go 1.13](https://golang.org/dl/) or greater.
80-
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater.
80+
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.
8181

82-
If pre-built frontend files are present it is possible to only build the backend:
82+
When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.
8383

84-
TAGS="bindata" make backend
85-
86-
Parallelism is not supported for these targets, so please don't include `-j <num>`.
84+
Parallelism (`make -j <num>`) is not supported.
8785

8886
More info: https://docs.gitea.io/en-us/install-from-source/
8987

cmd/admin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ func runDeleteUser(c *cli.Context) error {
512512
return models.DeleteUser(user)
513513
}
514514

515-
func runRepoSyncReleases(c *cli.Context) error {
515+
func runRepoSyncReleases(_ *cli.Context) error {
516516
if err := initDB(); err != nil {
517517
return err
518518
}
@@ -578,14 +578,14 @@ func getReleaseCount(id int64) (int64, error) {
578578
)
579579
}
580580

581-
func runRegenerateHooks(c *cli.Context) error {
581+
func runRegenerateHooks(_ *cli.Context) error {
582582
if err := initDB(); err != nil {
583583
return err
584584
}
585585
return repo_module.SyncRepositoryHooks(graceful.GetManager().ShutdownContext())
586586
}
587587

588-
func runRegenerateKeys(c *cli.Context) error {
588+
func runRegenerateKeys(_ *cli.Context) error {
589589
if err := initDB(); err != nil {
590590
return err
591591
}

cmd/hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Gitea or set your environment appropriately.`, "")
166166
}
167167

168168
// the environment setted on serv command
169-
isUncyclo := (os.Getenv(models.EnvRepoIsUncyclo) == "true")
169+
isUncyclo := os.Getenv(models.EnvRepoIsUncyclo) == "true"
170170
username := os.Getenv(models.EnvRepoUsername)
171171
reponame := os.Getenv(models.EnvRepoName)
172172
userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
@@ -322,7 +322,7 @@ Gitea or set your environment appropriately.`, "")
322322

323323
// the environment setted on serv command
324324
repoUser := os.Getenv(models.EnvRepoUsername)
325-
isUncyclo := (os.Getenv(models.EnvRepoIsUncyclo) == "true")
325+
isUncyclo := os.Getenv(models.EnvRepoIsUncyclo) == "true"
326326
repoName := os.Getenv(models.EnvRepoName)
327327
pusherID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
328328
pusherName := os.Getenv(models.EnvPusherName)

cmd/web_graceful.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"net"
1010
"net/http"
1111
"net/http/fcgi"
12+
"strings"
1213

1314
"code.gitea.io/gitea/modules/graceful"
1415
"code.gitea.io/gitea/modules/log"
16+
"code.gitea.io/gitea/modules/setting"
1517
)
1618

1719
func runHTTP(network, listenAddr, name string, m http.Handler) error {
@@ -48,7 +50,12 @@ func runFCGI(network, listenAddr, name string, m http.Handler) error {
4850
fcgiServer := graceful.NewServer(network, listenAddr, name)
4951

5052
err := fcgiServer.ListenAndServe(func(listener net.Listener) error {
51-
return fcgi.Serve(listener, m)
53+
return fcgi.Serve(listener, http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
54+
if setting.AppSubURL != "" {
55+
req.URL.Path = strings.TrimPrefix(req.URL.Path, setting.AppSubURL)
56+
}
57+
m.ServeHTTP(resp, req)
58+
}))
5259
})
5360
if err != nil {
5461
log.Fatal("Failed to start FCGI main server: %v", err)

models/branches.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,6 @@ func (protectBranch *ProtectedBranch) IsProtectedFile(patterns []glob.Glob, path
260260
return r
261261
}
262262

263-
// GetProtectedBranchByRepoID getting protected branch by repo ID
264-
func GetProtectedBranchByRepoID(repoID int64) ([]*ProtectedBranch, error) {
265-
protectedBranches := make([]*ProtectedBranch, 0)
266-
return protectedBranches, x.Where("repo_id = ?", repoID).Desc("updated_unix").Find(&protectedBranches)
267-
}
268-
269263
// GetProtectedBranchBy getting protected branch by ID/Name
270264
func GetProtectedBranchBy(repoID int64, branchName string) (*ProtectedBranch, error) {
271265
return getProtectedBranchBy(x, repoID, branchName)
@@ -283,19 +277,6 @@ func getProtectedBranchBy(e Engine, repoID int64, branchName string) (*Protected
283277
return rel, nil
284278
}
285279

286-
// GetProtectedBranchByID getting protected branch by ID
287-
func GetProtectedBranchByID(id int64) (*ProtectedBranch, error) {
288-
rel := &ProtectedBranch{}
289-
has, err := x.ID(id).Get(rel)
290-
if err != nil {
291-
return nil, err
292-
}
293-
if !has {
294-
return nil, nil
295-
}
296-
return rel, nil
297-
}
298-
299280
// WhitelistOptions represent all sorts of whitelists used for protected branches
300281
type WhitelistOptions struct {
301282
UserIDs []int64

models/issue_label.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -510,19 +510,6 @@ func GetLabelIDsInOrgByNames(orgID int64, labelNames []string) ([]int64, error)
510510
Find(&labelIDs)
511511
}
512512

513-
// GetLabelIDsInOrgsByNames returns a list of labelIDs by names in one of the given
514-
// organization.
515-
// it silently ignores label names that do not belong to the organization.
516-
func GetLabelIDsInOrgsByNames(orgIDs []int64, labelNames []string) ([]int64, error) {
517-
labelIDs := make([]int64, 0, len(labelNames))
518-
return labelIDs, x.Table("label").
519-
In("org_id", orgIDs).
520-
In("name", labelNames).
521-
Asc("name").
522-
Cols("id").
523-
Find(&labelIDs)
524-
}
525-
526513
// GetLabelInOrgByID returns a label by ID in given organization.
527514
func GetLabelInOrgByID(orgID, labelID int64) (*Label, error) {
528515
return getLabelInOrgByID(x, orgID, labelID)

models/lfs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ func (repo *Repository) CountLFSMetaObjects() (int64, error) {
131131
func LFSObjectAccessible(user *User, oid string) (bool, error) {
132132
if user.IsAdmin {
133133
count, err := x.Count(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
134-
return (count > 0), err
134+
return count > 0, err
135135
}
136136
cond := accessibleRepositoryCondition(user)
137137
count, err := x.Where(cond).Join("INNER", "repository", "`lfs_meta_object`.repository_id = `repository`.id").Count(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
138-
return (count > 0), err
138+
return count > 0, err
139139
}
140140

141141
// LFSAutoAssociate auto associates accessible LFSMetaObjects

models/repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestGetRepositoryCount(t *testing.T) {
7575
assert.NoError(t, err2)
7676
assert.NoError(t, err3)
7777
assert.Equal(t, int64(3), count)
78-
assert.Equal(t, (privateCount + publicCount), count)
78+
assert.Equal(t, privateCount+publicCount, count)
7979
}
8080

8181
func TestGetPublicRepositoryCount(t *testing.T) {

models/user.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ const (
7676
)
7777

7878
var (
79-
// ErrUserNotKeyOwner user does not own this key error
80-
ErrUserNotKeyOwner = errors.New("User does not own this public key")
81-
8279
// ErrEmailNotExist e-mail does not exist error
8380
ErrEmailNotExist = errors.New("E-mail does not exist")
8481

@@ -239,10 +236,10 @@ func (u *User) GetEmail() string {
239236
return u.Email
240237
}
241238

242-
// GetAllUsers returns a slice of all users found in DB.
239+
// GetAllUsers returns a slice of all individual users found in DB.
243240
func GetAllUsers() ([]*User, error) {
244241
users := make([]*User, 0)
245-
return users, x.OrderBy("id").Find(&users)
242+
return users, x.OrderBy("id").Where("type = ?", UserTypeIndividual).Find(&users)
246243
}
247244

248245
// IsLocal returns true if user login type is LoginPlain.

models/user_heatmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func getUserHeatmapData(user *User, team *Team, doer *User) ([]*UserHeatmapData,
6565
Select(groupBy+" AS timestamp, count(user_id) as contributions").
6666
Table("action").
6767
Where(cond).
68-
And("created_unix > ?", (timeutil.TimeStampNow() - 31536000)).
68+
And("created_unix > ?", timeutil.TimeStampNow()-31536000).
6969
GroupBy(groupByName).
7070
OrderBy("timestamp").
7171
Find(&hdata)

models/user_openid.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func GetUserOpenIDs(uid int64) ([]*UserOpenID, error) {
3535
return openids, nil
3636
}
3737

38+
// isOpenIDUsed returns true if the openid has been used.
3839
func isOpenIDUsed(e Engine, uri string) (bool, error) {
3940
if len(uri) == 0 {
4041
return true, nil
@@ -43,11 +44,6 @@ func isOpenIDUsed(e Engine, uri string) (bool, error) {
4344
return e.Get(&UserOpenID{URI: uri})
4445
}
4546

46-
// IsOpenIDUsed returns true if the openid has been used.
47-
func IsOpenIDUsed(openid string) (bool, error) {
48-
return isOpenIDUsed(x, openid)
49-
}
50-
5147
// NOTE: make sure openid.URI is normalized already
5248
func addUserOpenID(e Engine, openid *UserOpenID) error {
5349
used, err := isOpenIDUsed(e, openid.URI)

modules/markup/common/linkify.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont
122122
}
123123
}
124124
}
125-
if m == nil {
126-
return nil
127-
}
125+
128126
if consumes != 0 {
129127
s := segment.WithStop(segment.Start + 1)
130128
ast.MergeOrAppendTextSegment(parent, s)

0 commit comments

Comments
 (0)