Skip to content

Commit 71b3cea

Browse files
authored
Merge branch 'master' into assets_dir
2 parents 8c943e0 + e8693eb commit 71b3cea

30 files changed

+7884
-2559
lines changed

.drone.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ steps:
7070
- make checks-backend
7171
depends_on: [lint-backend]
7272

73+
- name: test-frontend
74+
image: node:14
75+
commands:
76+
- make test-frontend
77+
depends_on: [lint-frontend]
78+
7379
- name: build-frontend
7480
image: node:14
7581
commands:
7682
- make frontend
77-
depends_on: [lint-frontend]
83+
depends_on: [test-frontend]
7884

7985
- name: build-backend-no-gcc
8086
pull: always

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ overrides:
5252
rules:
5353
import/no-unresolved: [0]
5454
import/no-extraneous-dependencies: [0]
55+
- files: ["*.test.js"]
56+
env:
57+
jest: true
58+
- files: ["*.config.js"]
59+
rules:
60+
import/no-unused-modules: [0]
5561

5662
rules:
5763
accessor-pairs: [2]

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.14.0-RC2](https://github.com/go-gitea/gitea/releases/tag/v1.14.0-rc2) - 2021-03-22
8+
9+
* SECURITY
10+
* Fix bug on avatar middleware (#15124) (#15125)
11+
* Fix another clusterfuzz identified issue (#15096) (#15113)
12+
* Update to goldmark 1.3.3 (#15059) (#15060)
13+
* BUGFIXES
14+
* Fix the v176 migration (#15110) (#15111)
15+
* Fix double 'push tag' action feed (#15078) (#15083)
16+
* Remove possible resource leak (#15067) (#15082)
17+
* Handle unauthorized user events gracefully (#15071) (#15074)
18+
719
## [1.14.0-RC1](https://github.com/go-gitea/gitea/releases/tag/v1.14.0-rc1) - 2021-03-19
820

921
* SECURITY
@@ -267,6 +279,31 @@ been added to each release, please refer to the [blog](https://blog.gitea.io).
267279
* Reduce make verbosity (#13803)
268280
* Add git command error directory on log (#13194)
269281

282+
## [1.13.7](https://github.com/go-gitea/gitea/releases/tag/v1.13.7) - 2021-04-07
283+
284+
* SECURITY
285+
* Update to bluemonday-1.0.6 (#15294) (#15298)
286+
* Clusterfuzz found another way (#15160) (#15169)
287+
* API
288+
* Fix wrong user returned in API (#15139) (#15150)
289+
* BUGFIXES
290+
* Add 'fonts' into 'KnownPublicEntries' (#15188) (#15317)
291+
* Speed up `enry.IsVendor` (#15213) (#15246)
292+
* Response 404 for diff/patch of a commit that not exist (#15221) (#15238)
293+
* Prevent NPE in CommentMustAsDiff if no hunk header (#15199) (#15201)
294+
* MISC
295+
* Add size to Save function (#15264) (#15271)
296+
297+
## [1.13.6](https://github.com/go-gitea/gitea/releases/tag/v1.13.6) - 2021-03-23
298+
299+
* SECURITY
300+
* Fix bug on avatar middleware (#15124) (#15125)
301+
* Fix another clusterfuzz identified issue (#15096) (#15114)
302+
* API
303+
* Fix nil exeption for get pull reviews API #15104 (#15106)
304+
* BUGFIXES
305+
* Fix markdown rendering in milestone content (#15056) (#15092)
306+
270307
## [1.13.5](https://github.com/go-gitea/gitea/releases/tag/v1.13.5) - 2021-03-21
271308

272309
* SECURITY

Makefile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ COMMA := ,
2828

2929
XGO_VERSION := go-1.16.x
3030
MIN_GO_VERSION := 001014000
31-
MIN_NODE_VERSION := 010013000
31+
MIN_NODE_VERSION := 012017000
3232

3333
DOCKER_IMAGE ?= gitea/gitea
3434
DOCKER_TAG ?= latest
@@ -173,6 +173,9 @@ help:
173173
@echo " - checks run various consistency checks"
174174
@echo " - checks-frontend check frontend files"
175175
@echo " - checks-backend check backend files"
176+
@echo " - test test everything"
177+
@echo " - test-frontend test frontend files"
178+
@echo " - test-backend test backend files"
176179
@echo " - webpack build webpack files"
177180
@echo " - svg build svg files"
178181
@echo " - fomantic build fomantic files"
@@ -322,7 +325,7 @@ lint: lint-frontend lint-backend
322325

323326
.PHONY: lint-frontend
324327
lint-frontend: node_modules
325-
npx eslint --color --max-warnings=0 web_src/js build templates webpack.config.js
328+
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js
326329
npx stylelint --color --max-warnings=0 web_src/less
327330

328331
.PHONY: lint-backend
@@ -345,16 +348,23 @@ watch-backend: go-check
345348
air -c .air.conf
346349

347350
.PHONY: test
348-
test:
351+
test: test-frontend test-backend
352+
353+
.PHONY: test-backend
354+
test-backend:
349355
@echo "Running go test with -tags '$(TEST_TAGS)'..."
350356
@$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='$(TEST_TAGS)' $(GO_PACKAGES)
351357

358+
.PHONY: test-frontend
359+
test-frontend:
360+
@NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --color
361+
352362
.PHONY: test-check
353363
test-check:
354364
@echo "Running test-check...";
355365
@diff=$$(git status -s); \
356366
if [ -n "$$diff" ]; then \
357-
echo "make test has changed files in the source tree:"; \
367+
echo "make test-backend has changed files in the source tree:"; \
358368
echo "$${diff}"; \
359369
echo "You should change the tests to create these files in a temporary directory."; \
360370
echo "Do not simply add these files to .gitignore"; \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ 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 10.13](https://nodejs.org/en/download/) or greater.
80+
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater.
8181

8282
If pre-built frontend files are present it is possible to only build the backend:
8383

build/generate-images.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#!/usr/bin/env node
2-
'use strict';
3-
4-
const imageminZopfli = require('imagemin-zopfli');
5-
const {optimize, extendDefaultPlugins} = require('svgo');
6-
const {fabric} = require('fabric');
7-
const {readFile, writeFile} = require('fs').promises;
8-
const {resolve} = require('path');
1+
import imageminZopfli from 'imagemin-zopfli';
2+
import {optimize, extendDefaultPlugins} from 'svgo';
3+
import {fabric} from 'fabric';
4+
import {readFile, writeFile} from 'fs/promises';
5+
import {resolve, dirname} from 'path';
6+
import {fileURLToPath} from 'url';
97

8+
const __dirname = dirname(fileURLToPath(import.meta.url));
109
const logoFile = resolve(__dirname, '../assets/logo.svg');
1110

1211
function exit(err) {

build/generate-svg.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#!/usr/bin/env node
2-
'use strict';
3-
4-
const fastGlob = require('fast-glob');
5-
const {optimize, extendDefaultPlugins} = require('svgo');
6-
const {resolve, parse} = require('path');
7-
const {readFile, writeFile, mkdir} = require('fs').promises;
1+
import fastGlob from 'fast-glob';
2+
import {optimize, extendDefaultPlugins} from 'svgo';
3+
import {resolve, parse, dirname} from 'path';
4+
import {readFile, writeFile, mkdir} from 'fs/promises';
5+
import {fileURLToPath} from 'url';
86

7+
const __dirname = dirname(fileURLToPath(import.meta.url));
98
const glob = (pattern) => fastGlob.sync(pattern, {cwd: resolve(__dirname), absolute: true});
109
const outputDir = resolve(__dirname, '../public/img/svg');
1110

docs/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ params:
1818
description: Git with a cup of tea
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
21-
version: 1.13.6
21+
version: 1.13.7
2222
minGoVersion: 1.14
2323
goVersion: 1.16
24-
minNodeVersion: 10.13
24+
minNodeVersion: 12.17
2525

2626
outputs:
2727
home:

jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
setupFilesAfterEnv: ['jest-extended'],
3+
testTimeout: 20000,
4+
testMatch: [
5+
'**/web_src/**/*.test.js',
6+
],
7+
transform: {},
8+
verbose: false,
9+
};
10+

models/issue_milestone.go

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,12 @@ func GetMilestones(opts GetMilestonesOption) (MilestoneList, error) {
426426
}
427427

428428
// SearchMilestones search milestones
429-
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType string) (MilestoneList, error) {
429+
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType string, keyword string) (MilestoneList, error) {
430430
miles := make([]*Milestone, 0, setting.UI.IssuePagingNum)
431431
sess := x.Where("is_closed = ?", isClosed)
432+
if len(keyword) > 0 {
433+
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
434+
}
432435
if repoCond.IsValid() {
433436
sess.In("repo_id", builder.Select("id").From("repository").Where(repoCond))
434437
}
@@ -460,6 +463,7 @@ func GetMilestonesByRepoIDs(repoIDs []int64, page int, isClosed bool, sortType s
460463
page,
461464
isClosed,
462465
sortType,
466+
"",
463467
)
464468
}
465469

@@ -506,6 +510,38 @@ func GetMilestonesStatsByRepoCond(repoCond builder.Cond) (*MilestonesStats, erro
506510
return stats, nil
507511
}
508512

513+
// GetMilestonesStatsByRepoCondAndKw returns milestone statistic information for dashboard by given repo conditions and name keyword.
514+
func GetMilestonesStatsByRepoCondAndKw(repoCond builder.Cond, keyword string) (*MilestonesStats, error) {
515+
var err error
516+
stats := &MilestonesStats{}
517+
518+
sess := x.Where("is_closed = ?", false)
519+
if len(keyword) > 0 {
520+
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
521+
}
522+
if repoCond.IsValid() {
523+
sess.And(builder.In("repo_id", builder.Select("id").From("repository").Where(repoCond)))
524+
}
525+
stats.OpenCount, err = sess.Count(new(Milestone))
526+
if err != nil {
527+
return nil, err
528+
}
529+
530+
sess = x.Where("is_closed = ?", true)
531+
if len(keyword) > 0 {
532+
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
533+
}
534+
if repoCond.IsValid() {
535+
sess.And(builder.In("repo_id", builder.Select("id").From("repository").Where(repoCond)))
536+
}
537+
stats.ClosedCount, err = sess.Count(new(Milestone))
538+
if err != nil {
539+
return nil, err
540+
}
541+
542+
return stats, nil
543+
}
544+
509545
func countRepoMilestones(e Engine, repoID int64) (int64, error) {
510546
return e.
511547
Where("repo_id=?", repoID).
@@ -548,6 +584,34 @@ func CountMilestonesByRepoCond(repoCond builder.Cond, isClosed bool) (map[int64]
548584
return countMap, nil
549585
}
550586

587+
// CountMilestonesByRepoCondAndKw map from repo conditions and the keyword of milestones' name to number of milestones matching the options`
588+
func CountMilestonesByRepoCondAndKw(repoCond builder.Cond, keyword string, isClosed bool) (map[int64]int64, error) {
589+
sess := x.Where("is_closed = ?", isClosed)
590+
if len(keyword) > 0 {
591+
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
592+
}
593+
if repoCond.IsValid() {
594+
sess.In("repo_id", builder.Select("id").From("repository").Where(repoCond))
595+
}
596+
597+
countsSlice := make([]*struct {
598+
RepoID int64
599+
Count int64
600+
}, 0, 10)
601+
if err := sess.GroupBy("repo_id").
602+
Select("repo_id AS repo_id, COUNT(*) AS count").
603+
Table("milestone").
604+
Find(&countsSlice); err != nil {
605+
return nil, err
606+
}
607+
608+
countMap := make(map[int64]int64, len(countsSlice))
609+
for _, c := range countsSlice {
610+
countMap[c.RepoID] = c.Count
611+
}
612+
return countMap, nil
613+
}
614+
551615
func updateRepoMilestoneNum(e Engine, repoID int64) error {
552616
_, err := e.Exec("UPDATE `repository` SET num_milestones=(SELECT count(*) FROM milestone WHERE repo_id=?),num_closed_milestones=(SELECT count(*) FROM milestone WHERE repo_id=? AND is_closed=?) WHERE id=?",
553617
repoID,

0 commit comments

Comments
 (0)