Skip to content

Commit 5775cc9

Browse files
authored
Merge branch 'master' into fix/system_webhooks_menu
2 parents adeabd9 + f76c300 commit 5775cc9

File tree

101 files changed

+1804
-382
lines changed

Some content is hidden

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

101 files changed

+1804
-382
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
open_collective: gitea
2+
custom: https://www.bountysource.com/teams/gitea

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Mura Li <[email protected]> (@typeless)
3636
6543 <[email protected]> (@6543)
3737
jaqra <[email protected]> (@jaqra)
3838
David Svantesson <[email protected]> (@davidsvantesson)
39-
CirnoT <[email protected]> (@CirnoT)
4039
a1012112796 <[email protected]> (@a1012112796)
4140
Karl Heinz Marbaise <[email protected]> (@khmarbaise)
4241
Norwin Roosen <[email protected]> (@noerw)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea" title="TODOs">
4343
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea">
4444
</a>
45+
<a href="https://www.bountysource.com/teams/gitea" title="Bountysource">
46+
<img src="https://img.shields.io/bountysource/team/gitea/activity">
47+
</a>
4548
</p>
4649

4750
<p align="center">

README_ZH.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea" title="TODOs">
4343
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea">
4444
</a>
45+
<a href="https://img.shields.io/bountysource/team/gitea" title="Bountysource">
46+
<img src="https://img.shields.io/bountysource/team/gitea/activity">
47+
</a>
4548
</p>
4649

4750
<p align="center">

cmd/admin.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,11 @@ func runChangePassword(c *cli.Context) error {
349349
if err != nil {
350350
return err
351351
}
352-
if user.Salt, err = models.GetUserSalt(); err != nil {
352+
if err = user.SetPassword(c.String("password")); err != nil {
353353
return err
354354
}
355-
user.HashPassword(c.String("password"))
356355

357-
if err := models.UpdateUserCols(user, "passwd", "passwd_hash_algo", "salt"); err != nil {
356+
if err = models.UpdateUserCols(user, "passwd", "passwd_hash_algo", "salt"); err != nil {
358357
return err
359358
}
360359

custom/conf/app.example.ini

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
; This file lists the default values used by Gitea
22
; Copy required sections to your own app.ini (default is custom/conf/app.ini)
33
; and modify as needed.
4+
; Do not copy the whole file as-is, as it contains some invalid sections for illustrative purposes.
5+
; If you don't know what a setting is you should not set it.
46

57
; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
68

@@ -242,6 +244,10 @@ TIMEOUT_STEP = 10s
242244
; If the browser client supports EventSource and SharedWorker, a SharedWorker will be used in preference to polling notification. Set to -1 to disable the EventSource
243245
EVENT_SOURCE_UPDATE_TIME = 10s
244246

247+
[ui.svg]
248+
; Whether to render SVG files as images. If SVG rendering is disabled, SVG files are displayed as text and cannot be embedded in markdown files as images.
249+
ENABLE_RENDER = true
250+
245251
[markdown]
246252
; Render soft line breaks as hard line breaks, which means a single newline character between
247253
; paragraphs will cause a line break and adding trailing whitespace to paragraphs is not
@@ -451,10 +457,13 @@ ISSUE_INDEXER_NAME = gitea_issues
451457
ISSUE_INDEXER_PATH = indexers/issues.bleve
452458
; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue
453459
ISSUE_INDEXER_QUEUE_TYPE = levelqueue
454-
; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the queue will be saved path,
460+
; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
461+
; This can be overriden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
455462
; default is indexers/issues.queue
456463
ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
457464
; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
465+
; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
466+
; the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
458467
ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
459468
; Batch queue number, default is 20
460469
ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20
@@ -494,6 +503,8 @@ LENGTH = 20
494503
; Batch size to send for batched queues
495504
BATCH_LENGTH = 20
496505
; Connection string for redis queues this will store the redis connection string.
506+
; When `TYPE` is `persistable-channel`, this provides a directory for the underlying leveldb
507+
; or additional options of the form `leveldb://path/to/db?option=value&....`, and will override `DATADIR`.
497508
CONN_STR = "addrs=127.0.0.1:6379 db=0"
498509
; Provides the suffix of the default redis/disk queue name - specific queues can be overriden within in their [queue.name] sections.
499510
QUEUE_NAME = "_queue"
@@ -856,7 +867,7 @@ MACARON = file
856867
ROUTER_LOG_LEVEL = Info
857868
ROUTER = console
858869
ENABLE_ACCESS_LOG = false
859-
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
870+
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
860871
ACCESS = file
861872
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace"
862873
LEVEL = Info

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
194194
- `TIMEOUT_STEP`: **10s**.
195195
- `EVENT_SOURCE_UPDATE_TIME`: **10s**: This setting determines how often the database is queried to update notification counts. If the browser client supports `EventSource` and `SharedWorker`, a `SharedWorker` will be used in preference to polling notification endpoint. Set to **-1** to disable the `EventSource`.
196196

197+
### UI - SVG Images (`ui.svg`)
198+
199+
- `ENABLE_RENDER`: **true**: Whether to render SVG files as images. If SVG rendering is disabled, SVG files are displayed as text and cannot be embedded in markdown files as images.
200+
197201
## Markdown (`markdown`)
198202

199203
- `ENABLE_HARD_LINE_BREAK_IN_COMMENTS`: **true**: Render soft line breaks as hard line breaks in comments, which
@@ -331,8 +335,8 @@ relation to port exhaustion.
331335
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
332336
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
333337
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
334-
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the queue will be saved path.
335-
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
338+
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved.
339+
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
336340
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
337341

338342
- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size).
@@ -350,11 +354,11 @@ relation to port exhaustion.
350354

351355
## Queue (`queue` and `queue.*`)
352356

353-
- `TYPE`: **persistable-channel**: General queue type, currently support: `persistable-channel`, `channel`, `level`, `redis`, `dummy`
357+
- `TYPE`: **persistable-channel**: General queue type, currently support: `persistable-channel` (uses a LevelDB internally), `channel`, `level`, `redis`, `dummy`
354358
- `DATADIR`: **queues/**: Base DataDir for storing persistent and level queues. `DATADIR` for individual queues can be set in `queue.name` sections but will default to `DATADIR/`**`name`**.
355359
- `LENGTH`: **20**: Maximal queue size before channel queues block
356360
- `BATCH_LENGTH`: **20**: Batch data before passing to the handler
357-
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. Options can be set using query params. Similarly LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**
361+
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. Options can be set using query params. Similarly LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**, and will override `DATADIR`
358362
- `QUEUE_NAME`: **_queue**: The suffix for default redis and disk queue name. Individual queues will default to **`name`**`QUEUE_NAME` but can be overriden in the specific `queue.name` section.
359363
- `SET_NAME`: **_unique**: The suffix that will be added to the default redis and disk queue `set` name for unique queues. Individual queues will default to
360364
**`name`**`QUEUE_NAME`_`SET_NAME`_ but can be overridden in the specific `queue.name` section.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.14
55
require (
66
code.gitea.io/gitea-vet v0.2.1
77
code.gitea.io/sdk/gitea v0.13.1
8-
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27
8+
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee
99
gitea.com/lunny/levelqueue v0.3.0
1010
gitea.com/macaron/binding v0.0.0-20190822013154-a5f53841ed2b
1111
gitea.com/macaron/cache v0.0.0-20200924044943-905232fba10b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFj
4040
code.gitea.io/sdk/gitea v0.13.1 h1:Y7bpH2iO6Q0KhhMJfjP/LZ0AmiYITeRQlCD8b0oYqhk=
4141
code.gitea.io/sdk/gitea v0.13.1/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
4242
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
43-
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27 h1:cdb1OTNXGLwQ55gg+9tIPWufdsnrHWcIq8Qs+j/E8JU=
44-
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27/go.mod h1:Ozg8IchVNb/Udg+ui39iHRYqVHSvf3C99ixdpLR8Vu0=
43+
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee h1:9U6HuKUBt/cGK6T/64dEuz0r7Yp97WAAEJvXHDlY3ws=
44+
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee/go.mod h1:Ozg8IchVNb/Udg+ui39iHRYqVHSvf3C99ixdpLR8Vu0=
4545
gitea.com/lunny/levelqueue v0.3.0 h1:MHn1GuSZkxvVEDMyAPqlc7A3cOW+q8RcGhRgH/xtm6I=
4646
gitea.com/lunny/levelqueue v0.3.0/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
4747
gitea.com/lunny/log v0.0.0-20190322053110-01b5df579c4e h1:r1en/D7xJmcY24VkHkjkcJFa+7ZWubVWPBrvsHkmHxk=

integrations/admin_user_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright 2021 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.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"strconv"
10+
"testing"
11+
12+
"code.gitea.io/gitea/models"
13+
14+
"github.com/stretchr/testify/assert"
15+
)
16+
17+
func TestAdminViewUsers(t *testing.T) {
18+
prepareTestEnv(t)
19+
20+
session := loginUser(t, "user1")
21+
req := NewRequest(t, "GET", "/admin/users")
22+
session.MakeRequest(t, req, http.StatusOK)
23+
24+
session = loginUser(t, "user2")
25+
req = NewRequest(t, "GET", "/admin/users")
26+
session.MakeRequest(t, req, http.StatusForbidden)
27+
}
28+
29+
func TestAdminViewUser(t *testing.T) {
30+
prepareTestEnv(t)
31+
32+
session := loginUser(t, "user1")
33+
req := NewRequest(t, "GET", "/admin/users/1")
34+
session.MakeRequest(t, req, http.StatusOK)
35+
36+
session = loginUser(t, "user2")
37+
req = NewRequest(t, "GET", "/admin/users/1")
38+
session.MakeRequest(t, req, http.StatusForbidden)
39+
}
40+
41+
func TestAdminEditUser(t *testing.T) {
42+
prepareTestEnv(t)
43+
44+
testSuccessfullEdit(t, models.User{ID: 2, Name: "newusername", LoginName: "otherlogin", Email: "[email protected]"})
45+
}
46+
47+
func testSuccessfullEdit(t *testing.T, formData models.User) {
48+
makeRequest(t, formData, http.StatusFound)
49+
}
50+
51+
func makeRequest(t *testing.T, formData models.User, headerCode int) {
52+
session := loginUser(t, "user1")
53+
csrf := GetCSRF(t, session, "/admin/users/"+strconv.Itoa(int(formData.ID)))
54+
req := NewRequestWithValues(t, "POST", "/admin/users/"+strconv.Itoa(int(formData.ID)), map[string]string{
55+
"_csrf": csrf,
56+
"user_name": formData.Name,
57+
"login_name": formData.LoginName,
58+
"login_type": "0-0",
59+
"email": formData.Email,
60+
})
61+
62+
session.MakeRequest(t, req, headerCode)
63+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: formData.ID}).(*models.User)
64+
assert.Equal(t, formData.Name, user.Name)
65+
assert.Equal(t, formData.LoginName, user.LoginName)
66+
assert.Equal(t, formData.Email, user.Email)
67+
}
68+
69+
func TestAdminDeleteUser(t *testing.T) {
70+
defer prepareTestEnv(t)()
71+
72+
session := loginUser(t, "user1")
73+
74+
csrf := GetCSRF(t, session, "/admin/users/8")
75+
req := NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{
76+
"_csrf": csrf,
77+
})
78+
session.MakeRequest(t, req, http.StatusOK)
79+
80+
assertUserDeleted(t, 8)
81+
models.CheckConsistencyFor(t, &models.User{})
82+
}

integrations/api_issue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ func TestAPISearchIssues(t *testing.T) {
186186
req = NewRequest(t, "GET", link.String())
187187
resp = session.MakeRequest(t, req, http.StatusOK)
188188
DecodeJSON(t, resp, &apiIssues)
189-
assert.EqualValues(t, "12", resp.Header().Get("X-Total-Count"))
189+
assert.EqualValues(t, "14", resp.Header().Get("X-Total-Count"))
190190
assert.Len(t, apiIssues, 10) //there are more but 10 is page item limit
191191

192192
query.Add("limit", "20")
193193
link.RawQuery = query.Encode()
194194
req = NewRequest(t, "GET", link.String())
195195
resp = session.MakeRequest(t, req, http.StatusOK)
196196
DecodeJSON(t, resp, &apiIssues)
197-
assert.Len(t, apiIssues, 12)
197+
assert.Len(t, apiIssues, 14)
198198

199199
query = url.Values{"assigned": {"true"}, "state": {"all"}}
200200
link.RawQuery = query.Encode()

integrations/api_repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func TestAPISearchRepo(t *testing.T) {
7777
expectedResults
7878
}{
7979
{name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50&private=false", expectedResults: expectedResults{
80-
nil: {count: 28},
81-
user: {count: 28},
82-
user2: {count: 28}},
80+
nil: {count: 30},
81+
user: {count: 30},
82+
user2: {count: 30}},
8383
},
8484
{name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10&private=false", expectedResults: expectedResults{
8585
nil: {count: 10},

integrations/delete_user_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ func assertUserDeleted(t *testing.T, userID int64) {
2424
models.AssertNotExistsBean(t, &models.Star{UID: userID})
2525
}
2626

27-
func TestAdminDeleteUser(t *testing.T) {
28-
defer prepareTestEnv(t)()
29-
30-
session := loginUser(t, "user1")
31-
32-
csrf := GetCSRF(t, session, "/admin/users/8")
33-
req := NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{
34-
"_csrf": csrf,
35-
})
36-
session.MakeRequest(t, req, http.StatusOK)
37-
38-
assertUserDeleted(t, 8)
39-
models.CheckConsistencyFor(t, &models.User{})
40-
}
41-
4227
func TestUserDeleteAccount(t *testing.T) {
4328
defer prepareTestEnv(t)()
4429

integrations/download_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ func TestDownloadByID(t *testing.T) {
2323
assert.Equal(t, "# repo1\n\nDescription for repo1", resp.Body.String())
2424
}
2525

26+
func TestDownloadByIDForSVGUsesSecureHeaders(t *testing.T) {
27+
defer prepareTestEnv(t)()
28+
29+
session := loginUser(t, "user2")
30+
31+
// Request raw blob
32+
req := NewRequest(t, "GET", "/user2/repo2/raw/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b")
33+
resp := session.MakeRequest(t, req, http.StatusOK)
34+
35+
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy"))
36+
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
37+
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
38+
}
39+
2640
func TestDownloadByIDMedia(t *testing.T) {
2741
defer prepareTestEnv(t)()
2842

@@ -34,3 +48,17 @@ func TestDownloadByIDMedia(t *testing.T) {
3448

3549
assert.Equal(t, "# repo1\n\nDescription for repo1", resp.Body.String())
3650
}
51+
52+
func TestDownloadByIDMediaForSVGUsesSecureHeaders(t *testing.T) {
53+
defer prepareTestEnv(t)()
54+
55+
session := loginUser(t, "user2")
56+
57+
// Request raw blob
58+
req := NewRequest(t, "GET", "/user2/repo2/media/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b")
59+
resp := session.MakeRequest(t, req, http.StatusOK)
60+
61+
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy"))
62+
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
63+
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
64+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/master
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = true
4+
bare = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unnamed repository; edit this file 'description' to name the repository.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to check the commit log message taken by
4+
# applypatch from an e-mail message.
5+
#
6+
# The hook should exit with non-zero status after issuing an
7+
# appropriate message if it wants to stop the commit. The hook is
8+
# allowed to edit the commit message file.
9+
#
10+
# To enable this hook, rename this file to "applypatch-msg".
11+
12+
. git-sh-setup
13+
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
14+
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
15+
:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to check the commit log message.
4+
# Called by "git commit" with one argument, the name of the file
5+
# that has the commit message. The hook should exit with non-zero
6+
# status after issuing an appropriate message if it wants to stop the
7+
# commit. The hook is allowed to edit the commit message file.
8+
#
9+
# To enable this hook, rename this file to "commit-msg".
10+
11+
# Uncomment the below to add a Signed-off-by line to the message.
12+
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13+
# hook is more suited to it.
14+
#
15+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17+
18+
# This example catches duplicate Signed-off-by lines.
19+
20+
test "" = "$(grep '^Signed-off-by: ' "$1" |
21+
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22+
echo >&2 Duplicate Signed-off-by lines.
23+
exit 1
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to prepare a packed repository for use over
4+
# dumb transports.
5+
#
6+
# To enable this hook, rename this file to "post-update".
7+
8+
exec git update-server-info

0 commit comments

Comments
 (0)