Skip to content

Commit 53c0181

Browse files
Merge branch 'master' into feature/issue-5092
2 parents 2a57643 + efa4e6b commit 53c0181

File tree

79 files changed

+41837
-19875
lines changed

Some content is hidden

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

79 files changed

+41837
-19875
lines changed

.drone.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pipeline:
5656
event: [ push, tag, pull_request ]
5757

5858
build-without-gcc:
59-
image: golang:1.9
59+
image: golang:1.11
6060
pull: true
6161
commands:
6262
- go build -o gitea_no_gcc # test if build succeeds without the sqlite tag
@@ -67,7 +67,7 @@ pipeline:
6767
image: golang:1.11
6868
pull: true
6969
environment:
70-
TAGS: bindata sqlite
70+
TAGS: bindata sqlite sqlite_unlock_notify
7171
commands:
7272
- make clean
7373
- make generate
@@ -87,7 +87,7 @@ pipeline:
8787
pull: true
8888
group: test
8989
environment:
90-
TAGS: bindata sqlite
90+
TAGS: bindata sqlite sqlite_unlock_notify
9191
commands:
9292
- make unit-test-coverage
9393
when:
@@ -99,7 +99,7 @@ pipeline:
9999
pull: true
100100
group: test
101101
environment:
102-
TAGS: bindata sqlite
102+
TAGS: bindata sqlite sqlite_unlock_notify
103103
commands:
104104
- make test
105105
when:
@@ -117,17 +117,18 @@ pipeline:
117117
when:
118118
event: [ tag ]
119119

120-
# Commented until db locking have been resolved!
121-
# test-sqlite:
122-
# image: golang:1.10
123-
# pull: true
124-
# group: test
125-
# environment:
126-
# TAGS: bindata
127-
# commands:
128-
# - make test-sqlite
129-
# when:
130-
# event: [ push, tag, pull_request ]
120+
test-sqlite:
121+
image: golang:1.11
122+
pull: true
123+
group: test
124+
environment:
125+
TAGS: bindata
126+
commands:
127+
- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
128+
- apt-get install -y git-lfs
129+
- make test-sqlite
130+
when:
131+
event: [ push, tag, pull_request ]
131132

132133
test-mysql:
133134
image: golang:1.11
@@ -196,7 +197,7 @@ pipeline:
196197
image: karalabe/xgo-latest:latest
197198
pull: true
198199
environment:
199-
TAGS: bindata sqlite
200+
TAGS: bindata sqlite sqlite_unlock_notify
200201
commands:
201202
- export PATH=$PATH:$GOPATH/bin
202203
- make release

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
FROM golang:1.10-alpine3.7 AS build-env
55

66
ARG GITEA_VERSION
7-
ARG TAGS="sqlite"
7+
ARG TAGS="sqlite sqlite_unlock_notify"
88
ENV TAGS "bindata $TAGS"
99

1010
#Build deps

Gopkg.lock

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

Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ ignored = ["google.golang.org/appengine*"]
3939
name = "github.com/go-sql-driver/mysql"
4040
revision = "d523deb1b23d913de5bdada721a6071e71283618"
4141

42+
[[override]]
43+
name = "github.com/mattn/go-sqlite3"
44+
revision = "f3aa5ce89995fab8c7777f7821f689d9ac81c80f"
45+
4246
[[override]]
4347
name = "github.com/gorilla/mux"
4448
revision = "757bef944d0f21880861c2dd9c871ca543023cba"

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fmt-check:
159159

160160
.PHONY: test
161161
test:
162-
$(GO) test -tags=sqlite $(PACKAGES)
162+
$(GO) test -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
163163

164164
.PHONY: coverage
165165
coverage:
@@ -170,7 +170,7 @@ coverage:
170170

171171
.PHONY: unit-test-coverage
172172
unit-test-coverage:
173-
for PKG in $(PACKAGES); do $(GO) test -tags=sqlite -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
173+
for PKG in $(PACKAGES); do $(GO) test -tags='sqlite sqlite_unlock_notify' -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
174174

175175
.PHONY: vendor
176176
vendor:
@@ -234,7 +234,7 @@ integrations.test: $(SOURCES)
234234
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.test
235235

236236
integrations.sqlite.test: $(SOURCES)
237-
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite'
237+
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
238238

239239
integrations.cover.test: $(SOURCES)
240240
$(GO) test -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test

contrib/ide/vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"type": "go",
2020
"request": "launch",
2121
"mode": "debug",
22-
"buildFlags": "-tags=\"sqlite\"",
22+
"buildFlags": "-tags=\"sqlite sqlite_unlock_notify\"",
2323
"port": 2345,
2424
"host": "127.0.0.1",
2525
"program": "${workspaceRoot}/main.go",

contrib/ide/vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"focus": false,
3636
"panel": "shared"
3737
},
38-
"args": ["build", "-tags=\"sqlite\""],
38+
"args": ["build", "-tags=\"sqlite sqlite_unlock_notify\""],
3939
"linux": {
4040
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
4141
},

docker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
88
.PHONY: docker
99
docker:
1010
docker build --disable-content-trust=false -t $(DOCKER_REF) .
11-
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite" .
11+
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" .
1212

1313
.PHONY: docker-build
1414
docker-build:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
193193
- `RECAPTCHA_SECRET`: **""**: Go to https://www.google.com/recaptcha/admin to get a secret for recaptcha.
194194
- `RECAPTCHA_SITEKEY`: **""**: Go to https://www.google.com/recaptcha/admin to get a sitekey for recaptcha.
195195
- `DEFAULT_ENABLE_DEPENDENCIES`: **true** Enable this to have dependencies enabled by default.
196+
- `ENABLE_USER_HEATMAP`: **true** Enable this to display the heatmap on users profiles.
196197

197198
## Webhook (`webhook`)
198199

docs/content/doc/installation/from-source.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ provided to keep the build process as simple as possible.
6666
Depending on requirements, the following build tags can be included.
6767

6868
* `bindata`: Build a single monolithic binary, with all assets included.
69-
* `sqlite`: Enable support for a [SQLite3](https://sqlite.org/) database. Suggested only
69+
* `sqlite sqlite_unlock_notify`: Enable support for a [SQLite3](https://sqlite.org/) database. Suggested only
7070
for tiny installations.
7171
* `tidb`: Enable support for a [TiDB](https://github.com/pingcap/tidb) database.
7272
* `pam`: Enable support for PAM (Linux Pluggable Authentication Modules). Can be used to

docs/content/doc/installation/from-source.fr-fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ git checkout pr-xyz
5757
Comme nous regroupons déjà toutes les bibliothèques requises pour compiler Gitea, vous pouvez continuer avec le processus de compilation lui-même. Nous fournissons diverses [tâches Make](https://github.com/go-gitea/gitea/blob/master/Makefile) pour rendre le processus de construction aussi simple que possible. <a href='{{< relref "doc/advanced/make.fr-fr.md" >}}'>Voyez ici comment obtenir Make</a>. Selon vos besoins, vous pourrez éventuellement ajouter diverses options de compilation, vous pouvez choisir entre ces options :
5858

5959
* `bindata`: Intègre toutes les ressources nécessaires à l'exécution d'une instance de Gitea, ce qui rend un déploiement facile car il n'est pas nécessaire de se préoccuper des fichiers supplémentaires.
60-
* `sqlite`: Active la prise en charge d'une base de données [SQLite3](https://sqlite.org/), ceci n'est recommandé que pour les petites installations de Gitea.
60+
* `sqlite sqlite_unlock_notify`: Active la prise en charge d'une base de données [SQLite3](https://sqlite.org/), ceci n'est recommandé que pour les petites installations de Gitea.
6161
* `tidb`: Active la prise en charge d'une base de données [TiDB](https://github.com/pingcap/tidb), c'est une base de données simplet et basée sur des fichiers. Elle est comparable à SQLite.
6262
* `pam`: Active la prise en charge de PAM (mLinux Pluggable Authentication Modules), très utile si vos utilisateurs doivent être authentifiés avec les comptes du système.
6363

docs/content/doc/installation/from-source.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ git checkout v1.0.0
4747
我们已经将所有的依赖项拷贝到本工程,我们提供了一些 [编译选项](https://github.com/go-gitea/gitea/blob/master/Makefile) 来让编译更简单。你可以按照你的需求来设置编译开关,可用编译选项如下:
4848

4949
* `bindata`: 这个编译选项将会把运行Gitea所需的所有外部资源都打包到可执行文件中,这样部署将非常简单因为除了可执行程序将不再需要任何其他文件。
50-
* `sqlite`: 这个编译选项将启用SQLite3数据库的支持,建议只在少数人使用时使用这个模式。
50+
* `sqlite sqlite_unlock_notify`: 这个编译选项将启用SQLite3数据库的支持,建议只在少数人使用时使用这个模式。
5151
* `tidb`: 这个编译选项启用tidb嵌入式数据库的支持,他跟SQLite类似但是是用纯Go编写的。
5252
* `pam`: 这个编译选项将会启用 PAM (Linux Pluggable Authentication Modules) 认证,如果你使用这一认证模式的话需要开启这个选项。
5353

docs/content/doc/installation/from-source.zh-tw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ git checkout v1.0.0
4747
完成設定相依性套件環境等工作後,您就可以開始編譯工作了。我們提供了不同的[編譯選項](https://github.com/go-gitea/gitea/blob/master/Makefile) ,讓編譯過程更加簡單。您可以根據需求來調整編譯選項,底下是可用的編譯選項說明:
4848

4949
* `bindata`: 使用此標籤來嵌入所有 Gitea 相關資源,您不用擔心其他額外檔案,對於部署來說非常方便。
50-
* `sqlite`: 使用此標籤來啟用 [SQLite3](https://sqlite.org/) 資料庫,建議只有少數人時才使用此模式。
50+
* `sqlite sqlite_unlock_notify`: 使用此標籤來啟用 [SQLite3](https://sqlite.org/) 資料庫,建議只有少數人時才使用此模式。
5151
* `tidb`: 使用此標籤來啟用 [TiDB](https://github.com/pingcap/tidb) 資料庫,它是檔案形式的資料庫,跟 SQLite 類似。
5252
* `pam`: 使用此標籤來啟用 PAM (Linux Pluggable Authentication Modules) 認證,對於系統使用者來說,此方式最方便了。
5353

integrations/api_user_heatmap_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.package models
4+
5+
package integrations
6+
7+
import (
8+
"code.gitea.io/gitea/models"
9+
"fmt"
10+
"github.com/stretchr/testify/assert"
11+
"net/http"
12+
"testing"
13+
)
14+
15+
func TestUserHeatmap(t *testing.T) {
16+
prepareTestEnv(t)
17+
adminUsername := "user1"
18+
normalUsername := "user2"
19+
session := loginUser(t, adminUsername)
20+
21+
urlStr := fmt.Sprintf("/api/v1/users/%s/heatmap", normalUsername)
22+
req := NewRequest(t, "GET", urlStr)
23+
resp := session.MakeRequest(t, req, http.StatusOK)
24+
var heatmap []*models.UserHeatmapData
25+
DecodeJSON(t, resp, &heatmap)
26+
var dummyheatmap []*models.UserHeatmapData
27+
dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1540080000, Contributions: 1})
28+
29+
assert.Equal(t, dummyheatmap, heatmap)
30+
}

models/fixtures/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
act_user_id: 2
66
repo_id: 2
77
is_private: true
8+
created_unix: 1540139562
89

910
-
1011
id: 2

models/unit_tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func MainTest(m *testing.M, pathToGiteaRoot string) {
4848
setting.RunUser = "runuser"
4949
setting.SSH.Port = 3000
5050
setting.SSH.Domain = "try.gitea.io"
51+
setting.UseSQLite3 = true
5152
setting.RepoRootPath, err = ioutil.TempDir(os.TempDir(), "repos")
5253
if err != nil {
5354
fatalTestError("TempDir: %v\n", err)

models/user_heatmap.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.package models
4+
5+
package models
6+
7+
import (
8+
"code.gitea.io/gitea/modules/setting"
9+
"code.gitea.io/gitea/modules/util"
10+
)
11+
12+
// UserHeatmapData represents the data needed to create a heatmap
13+
type UserHeatmapData struct {
14+
Timestamp util.TimeStamp `json:"timestamp"`
15+
Contributions int64 `json:"contributions"`
16+
}
17+
18+
// GetUserHeatmapDataByUser returns an array of UserHeatmapData
19+
func GetUserHeatmapDataByUser(user *User) (hdata []*UserHeatmapData, err error) {
20+
var groupBy string
21+
switch {
22+
case setting.UseSQLite3:
23+
groupBy = "strftime('%s', strftime('%Y-%m-%d', created_unix, 'unixepoch'))"
24+
case setting.UseMySQL:
25+
groupBy = "UNIX_TIMESTAMP(DATE_FORMAT(FROM_UNIXTIME(created_unix), '%Y%m%d'))"
26+
case setting.UsePostgreSQL:
27+
groupBy = "extract(epoch from date_trunc('day', to_timestamp(created_unix)))"
28+
case setting.UseMSSQL:
29+
groupBy = "dateadd(DAY,0, datediff(day,0, dateadd(s, created_unix, '19700101')))"
30+
}
31+
32+
err = x.Select(groupBy+" as timestamp, count(user_id) as contributions").
33+
Table("action").
34+
Where("user_id = ?", user.ID).
35+
And("created_unix > ?", (util.TimeStampNow() - 31536000)).
36+
GroupBy("timestamp").
37+
OrderBy("timestamp").
38+
Find(&hdata)
39+
return
40+
}

models/user_heatmap_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.package models
4+
5+
package models
6+
7+
import (
8+
"github.com/stretchr/testify/assert"
9+
"testing"
10+
)
11+
12+
func TestGetUserHeatmapDataByUser(t *testing.T) {
13+
// Prepare
14+
assert.NoError(t, PrepareTestDatabase())
15+
16+
// Insert some action
17+
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
18+
19+
// get the action for comparison
20+
actions, err := GetFeeds(GetFeedsOptions{
21+
RequestedUser: user,
22+
RequestingUserID: user.ID,
23+
IncludePrivate: true,
24+
OnlyPerformedBy: false,
25+
IncludeDeleted: true,
26+
})
27+
assert.NoError(t, err)
28+
29+
// Get the heatmap and compare
30+
heatmap, err := GetUserHeatmapDataByUser(user)
31+
assert.NoError(t, err)
32+
assert.Equal(t, len(actions), len(heatmap))
33+
}

modules/auth/repo_form.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ type CodeCommentForm struct {
377377
Line int64
378378
TreePath string `form:"path" binding:"Required"`
379379
IsReview bool `form:"is_review"`
380+
Reply int64 `form:"reply"`
380381
}
381382

382383
// Validate validates the fields

modules/setting/setting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ var Service struct {
12181218
DefaultEnableDependencies bool
12191219
DefaultAllowOnlyContributorsToTrackTime bool
12201220
NoReplyAddress string
1221+
EnableUserHeatmap bool
12211222

12221223
// OpenID settings
12231224
EnableOpenIDSignIn bool
@@ -1249,6 +1250,7 @@ func newService() {
12491250
Service.DefaultEnableDependencies = sec.Key("DEFAULT_ENABLE_DEPENDENCIES").MustBool(true)
12501251
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
12511252
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
1253+
Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
12521254

12531255
sec = Cfg.Section("openid")
12541256
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ starred = Starred Repositories
320320
following = Following
321321
follow = Follow
322322
unfollow = Unfollow
323+
heatmap.loading = Loading Heatmap…
323324
324325
form.name_reserved = The username '%s' is reserved.
325326
form.name_pattern_not_allowed = The pattern '%s' is not allowed in a username.

public/css/index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/less/_base.less

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,20 @@ footer {
588588
border-bottom-width: 0 !important;
589589
margin-bottom: 2px !important;
590590
}
591+
592+
#user-heatmap{
593+
width: 107%; // Fixes newest contributions not showing
594+
text-align: center;
595+
margin: 40px 0 30px;
596+
597+
svg:not(:root) {
598+
overflow: inherit;
599+
padding: 0 !important;
600+
}
601+
602+
@media only screen and (max-width: 1200px) {
603+
& {
604+
display: none;
605+
}
606+
}
607+
}

public/less/_user.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
.ui.repository.list {
5959
margin-top: 25px;
6060
}
61+
62+
#loading-heatmap{
63+
margin-bottom: 1em;
64+
}
6165
}
6266

6367
&.followers {

0 commit comments

Comments
 (0)