mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-05 18:32:41 +09:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09bd05732d | ||
|
|
de7a76a995 | ||
|
|
357d5a5a3d | ||
|
|
d81cf34e37 | ||
|
|
9902317679 | ||
|
|
33e164168f | ||
|
|
f40ba68d57 | ||
|
|
cb0c8b8ae4 | ||
|
|
eba5945d2f | ||
|
|
4c67925531 | ||
|
|
3c60121ca7 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,4 +1,16 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
## [1.2.3](https://github.com/go-gitea/gitea/releases/tag/v1.2.3) - 2017-11-03
|
||||||
|
* BUGFIXES
|
||||||
|
* Only require one email when validating GPG key (#2266, #2467, #2663) (#2788)
|
||||||
|
* Fix order of comments (#2835) (#2839)
|
||||||
|
|
||||||
|
## [1.2.2](https://github.com/go-gitea/gitea/releases/tag/v1.2.2) - 2017-10-26
|
||||||
|
* BUGFIXES
|
||||||
|
* Add checks for commits with missing author and time (#2771) (#2785)
|
||||||
|
* Fix sending mail with a non-latin display name (#2559) (#2783)
|
||||||
|
* Sync MaxGitDiffLineCharacters with conf/app.ini (#2779) (#2780)
|
||||||
|
* Update vendor git (#2765) (#2772)
|
||||||
|
* Fix emojify image URL (#2769) (#2773)
|
||||||
|
|
||||||
## [1.2.1](https://github.com/go-gitea/gitea/releases/tag/v1.2.1) - 2017-10-16
|
## [1.2.1](https://github.com/go-gitea/gitea/releases/tag/v1.2.1) - 2017-10-16
|
||||||
* BUGFIXES
|
* BUGFIXES
|
||||||
|
|||||||
260
integrations/api_gpg_keys_test.go
Normal file
260
integrations/api_gpg_keys_test.go
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package integrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGPGKeys(t *testing.T) {
|
||||||
|
prepareTestEnv(t)
|
||||||
|
session := loginUser(t, "user2")
|
||||||
|
|
||||||
|
tt := []struct {
|
||||||
|
name string
|
||||||
|
reqBuilder func(testing.TB, *http.Request, int) *TestResponse
|
||||||
|
results []int
|
||||||
|
}{
|
||||||
|
{name: "NoLogin", reqBuilder: MakeRequest,
|
||||||
|
results: []int{http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized},
|
||||||
|
},
|
||||||
|
{name: "LoggedAsUser2", reqBuilder: session.MakeRequest,
|
||||||
|
results: []int{http.StatusOK, http.StatusOK, http.StatusNotFound, http.StatusNoContent, http.StatusInternalServerError, http.StatusInternalServerError, http.StatusCreated, http.StatusCreated}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tt {
|
||||||
|
|
||||||
|
//Basic test on result code
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
t.Run("ViewOwnGPGKeys", func(t *testing.T) {
|
||||||
|
testViewOwnGPGKeys(t, tc.reqBuilder, tc.results[0])
|
||||||
|
})
|
||||||
|
t.Run("ViewGPGKeys", func(t *testing.T) {
|
||||||
|
testViewGPGKeys(t, tc.reqBuilder, tc.results[1])
|
||||||
|
})
|
||||||
|
t.Run("GetGPGKey", func(t *testing.T) {
|
||||||
|
testGetGPGKey(t, tc.reqBuilder, tc.results[2])
|
||||||
|
})
|
||||||
|
t.Run("DeleteGPGKey", func(t *testing.T) {
|
||||||
|
testDeleteGPGKey(t, tc.reqBuilder, tc.results[3])
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("CreateInvalidGPGKey", func(t *testing.T) {
|
||||||
|
testCreateInvalidGPGKey(t, tc.reqBuilder, tc.results[4])
|
||||||
|
})
|
||||||
|
t.Run("CreateNoneRegistredEmailGPGKey", func(t *testing.T) {
|
||||||
|
testCreateNoneRegistredEmailGPGKey(t, tc.reqBuilder, tc.results[5])
|
||||||
|
})
|
||||||
|
t.Run("CreateValidGPGKey", func(t *testing.T) {
|
||||||
|
testCreateValidGPGKey(t, tc.reqBuilder, tc.results[6])
|
||||||
|
})
|
||||||
|
t.Run("CreateValidSecondaryEmailGPGKey", func(t *testing.T) {
|
||||||
|
testCreateValidSecondaryEmailGPGKey(t, tc.reqBuilder, tc.results[7])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check state after basic add
|
||||||
|
t.Run("CheckState", func(t *testing.T) {
|
||||||
|
|
||||||
|
var keys []*api.GPGKey
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/user/gpg_keys") //GET all keys
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &keys)
|
||||||
|
|
||||||
|
primaryKey1 := keys[0] //Primary key 1
|
||||||
|
assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID)
|
||||||
|
assert.EqualValues(t, 1, len(primaryKey1.Emails))
|
||||||
|
assert.EqualValues(t, "user2@example.com", primaryKey1.Emails[0].Email)
|
||||||
|
assert.EqualValues(t, true, primaryKey1.Emails[0].Verified)
|
||||||
|
|
||||||
|
subKey := primaryKey1.SubsKey[0] //Subkey of 38EA3BCED732982C
|
||||||
|
assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID)
|
||||||
|
assert.EqualValues(t, 0, len(subKey.Emails))
|
||||||
|
|
||||||
|
primaryKey2 := keys[1] //Primary key 2
|
||||||
|
assert.EqualValues(t, "FABF39739FE1E927", primaryKey2.KeyID)
|
||||||
|
assert.EqualValues(t, 1, len(primaryKey2.Emails))
|
||||||
|
assert.EqualValues(t, "user21@example.com", primaryKey2.Emails[0].Email)
|
||||||
|
assert.EqualValues(t, false, primaryKey2.Emails[0].Verified)
|
||||||
|
|
||||||
|
var key api.GPGKey
|
||||||
|
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey1.ID, 10)) //Primary key 1
|
||||||
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &key)
|
||||||
|
assert.EqualValues(t, "38EA3BCED732982C", key.KeyID)
|
||||||
|
assert.EqualValues(t, 1, len(key.Emails))
|
||||||
|
assert.EqualValues(t, "user2@example.com", key.Emails[0].Email)
|
||||||
|
assert.EqualValues(t, true, key.Emails[0].Verified)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(subKey.ID, 10)) //Subkey of 38EA3BCED732982C
|
||||||
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &key)
|
||||||
|
assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID)
|
||||||
|
assert.EqualValues(t, 0, len(key.Emails))
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey2.ID, 10)) //Primary key 2
|
||||||
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &key)
|
||||||
|
assert.EqualValues(t, "FABF39739FE1E927", key.KeyID)
|
||||||
|
assert.EqualValues(t, 1, len(key.Emails))
|
||||||
|
assert.EqualValues(t, "user21@example.com", key.Emails[0].Email)
|
||||||
|
assert.EqualValues(t, false, key.Emails[0].Verified)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
//Check state after basic add
|
||||||
|
t.Run("CheckCommits", func(t *testing.T) {
|
||||||
|
t.Run("NotSigned", func(t *testing.T) {
|
||||||
|
var branch api.Branch
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/not-signed")
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &branch)
|
||||||
|
assert.EqualValues(t, false, branch.Commit.Verification.Verified)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("SignedWithNotValidatedEmail", func(t *testing.T) {
|
||||||
|
var branch api.Branch
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign-not-yet-validated")
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &branch)
|
||||||
|
assert.EqualValues(t, false, branch.Commit.Verification.Verified)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("SignedWithValidEmail", func(t *testing.T) {
|
||||||
|
var branch api.Branch
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign")
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
DecodeJSON(t, resp, &branch)
|
||||||
|
assert.EqualValues(t, true, branch.Commit.Verification.Verified)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func testViewOwnGPGKeys(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/user/gpg_keys")
|
||||||
|
reqBuilder(t, req, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testViewGPGKeys(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/users/user2/gpg_keys")
|
||||||
|
reqBuilder(t, req, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGetGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
req := NewRequest(t, "GET", "/api/v1/user/gpg_keys/1")
|
||||||
|
reqBuilder(t, req, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDeleteGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
req := NewRequest(t, "DELETE", "/api/v1/user/gpg_keys/1")
|
||||||
|
reqBuilder(t, req, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCreateGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int, publicKey string) {
|
||||||
|
req := NewRequestWithJSON(t, "POST", "/api/v1/user/gpg_keys", api.CreateGPGKeyOption{
|
||||||
|
ArmoredKey: publicKey,
|
||||||
|
})
|
||||||
|
reqBuilder(t, req, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCreateInvalidGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
testCreateGPGKey(t, reqBuilder, expected, "invalid_key")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCreateNoneRegistredEmailGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
testCreateGPGKey(t, reqBuilder, expected, `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
mQENBFmGUygBCACjCNbKvMGgp0fd5vyFW9olE1CLCSyyF9gQN2hSuzmZLuAZF2Kh
|
||||||
|
dCMCG2T1UwzUB/yWUFWJ2BtCwSjuaRv+cGohqEy6bhEBV90peGA33lHfjx7wP25O
|
||||||
|
7moAphDOTZtDj1AZfCh/PTcJut8Lc0eRDMhNyp/bYtO7SHNT1Hr6rrCV/xEtSAvR
|
||||||
|
3b148/tmIBiSadaLwc558KU3ucjnW5RVGins3AjBZ+TuT4XXVH/oeLSeXPSJ5rt1
|
||||||
|
rHwaseslMqZ4AbvwFLx5qn1OC9rEQv/F548QsA8m0IntLjoPon+6wcubA9Gra21c
|
||||||
|
Fp6aRYl9x7fiqXDLg8i3s2nKdV7+e6as6Tp9ABEBAAG0FG5vdGtub3duQGV4YW1w
|
||||||
|
bGUuY29tiQEcBBABAgAGBQJZhlMoAAoJEC8+pvYULDtte/wH/2JNrhmHwDY+hMj0
|
||||||
|
batIK4HICnkKxjIgbha80P2Ao08NkzSge58fsxiKDFYAQjHui+ZAw4dq79Ax9AOO
|
||||||
|
Iv2GS9+DUfWhrb6RF+vNuJldFzcI0rTW/z2q+XGKrUCwN3khJY5XngHfQQrdBtMK
|
||||||
|
qsoUXz/5B8g422RTbo/SdPsyYAV6HeLLeV3rdgjI1fpaW0seZKHeTXQb/HvNeuPg
|
||||||
|
qz+XV1g6Gdqa1RjDOaX7A8elVKxrYq3LBtc93FW+grBde8n7JL0zPM3DY+vJ0IJZ
|
||||||
|
INx/MmBfmtCq05FqNclvU+sj2R3N1JJOtBOjZrJHQbJhzoILou8AkxeX1A+q9OAz
|
||||||
|
1geiY5E=
|
||||||
|
=TkP3
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCreateValidGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
//User2 <user2@example.com> //primary & activated
|
||||||
|
testCreateGPGKey(t, reqBuilder, expected, `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
mQENBFmGVsMBCACuxgZ7W7rI9xN08Y4M7B8yx/6/I4Slm94+wXf8YNRvAyqj30dW
|
||||||
|
VJhyBcnfNRDLKSQp5o/hhfDkCgdqBjLa1PnHlGS3PXJc0hP/FyYPD2BFvNMPpCYS
|
||||||
|
eu3T1qKSNXm6X0XOWD2LIrdiDC8HaI9FqZVMI/srMK2CF8XCL2m67W1FuoPlWzod
|
||||||
|
5ORy0IZB7spoF0xihmcgnEGElRmdo5w/vkGH8U7Zyn9Eb57UVFeafgeskf4wqB23
|
||||||
|
BjbMdW2YaB+yzMRwYgOnD5lnBD4uqSmvjaV9C0kxn7x+oJkkiRV8/z1cNcO+BaeQ
|
||||||
|
Akh/yTTeTzYGSc/ZOqCX1O+NOPgSeixVlqenABEBAAG0GVVzZXIyIDx1c2VyMkBl
|
||||||
|
eGFtcGxlLmNvbT6JAVQEEwEIAD4WIQRXgbSh0TtGbgRd7XI46jvO1zKYLAUCWYZW
|
||||||
|
wwIbAwUJA8JnAAULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRA46jvO1zKYLF/e
|
||||||
|
B/91wm2KLMIQBZBA9WA2/+9rQWTo9EqgYrXN60rEzX3cYJWXZiE4DrKR1oWDGNLi
|
||||||
|
KXOCW62snvJldolBqq0ZqaKvPKzl0Y5TRqbYEc9AjUSqgRin1b+G2DevLGT4ibq+
|
||||||
|
7ocQvz0XkASEUAgHahp0Ubiiib1521WwT/duL+AG8Gg0+DK09RfV3eX5/EOkQCKv
|
||||||
|
8cutqgsd2Smz40A8wXuJkRcipZBtrB/GkUaZ/eJdwEeSYZjEA9GWF61LJT2stvRN
|
||||||
|
HCk7C3z3pVEek1PluiFs/4VN8BG8yDzW4c0tLty4Fj3VwPqwIbB5AJbquVfhQCb4
|
||||||
|
Eep2lm3Lc9b1OwO5N3coPJkouQENBFmGVsMBCADAGba2L6NCOE1i3WIP6CPzbdOo
|
||||||
|
N3gdTfTgccAx9fNeon9jor+3tgEjlo9/6cXiRoksOV6W4wFab/ZwWgwN6JO4CGvZ
|
||||||
|
Wi7EQwMMMp1E36YTojKQJrcA9UvMnTHulqQQ88F5E845DhzFQM3erv42QZZMBAX3
|
||||||
|
kXCgy1GNFocl6tLUvJdEqs+VcJGGANMpmzE4WLa8KhSYnxipwuQ62JBy9R+cHyKT
|
||||||
|
OARk8znRqSu5bT3LtlrZ/HXu+6Oy4+2uCdNzZIh5J5tPS7CPA6ptl88iGVBte/CJ
|
||||||
|
7cjgJWSQqeYp2Y5QvsWAivkQ4Ww9plHbbwV0A2eaHsjjWzlUl3HoJ/snMOhBABEB
|
||||||
|
AAGJATwEGAEIACYWIQRXgbSh0TtGbgRd7XI46jvO1zKYLAUCWYZWwwIbDAUJA8Jn
|
||||||
|
AAAKCRA46jvO1zKYLBwLCACQOpeRVrwIKVaWcPMYjVHHJsGscaLKpgpARAUgbiG6
|
||||||
|
Cbc2WI8Sm3fRwrY0VAfN+u9QwrtvxANcyB3vTgTzw7FimfhOimxiTSO8HQCfjDZF
|
||||||
|
Xly8rq+Fua7+ClWUpy21IekW41VvZYjH2sL6EVP+UcEOaGAyN53XfhaRVZPhNtZN
|
||||||
|
NKAE9N5EG3rbsZ33LzJj40rEKlzFSseAAPft8qA3IXjzFBx+PQXHMpNCagL79he6
|
||||||
|
lqockTJ+oPmta4CF/J0U5LUr1tOZXheL3TP6m8d08gDrtn0YuGOPk87i9sJz+jR9
|
||||||
|
uy6MA3VSB99SK9ducGmE1Jv8mcziREroz2TEGr0zPs6h
|
||||||
|
=J59D
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCreateValidSecondaryEmailGPGKey(t *testing.T, reqBuilder func(testing.TB, *http.Request, int) *TestResponse, expected int) {
|
||||||
|
//User2 <user21@example.com> //secondary and not activated
|
||||||
|
testCreateGPGKey(t, reqBuilder, expected, `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
mQENBFmGWN4BCAC18V4tVGO65VLCV7p14FuXJlUtZ5CuYMvgEkcOqrvRaBSW9ao4
|
||||||
|
PGESOhJpfWpnW3QgJniYndLzPpsmdHEclEER6aZjiNgReWPOjHD5tykWocZAJqXD
|
||||||
|
eY1ym59gvVMLcfbV2yQsyR2hbJlc+dJsl16tigSEe3nwxZSw2IsW92pgEzT9JNUr
|
||||||
|
Q+mC8dw4dqY0tYmFazYUGNxufUc/twgQT/Or1aNs0az5Q6Jft4rrTRsh/S7We0VB
|
||||||
|
COKGkdcQyYgAls7HJBuPjQRi6DM9VhgBSHLAgSLyaUcZvhZBJr8Qe/q4PP3/kYDJ
|
||||||
|
wm4RMnjOLz2pFZPgtRqgcAwpmFtLrACbEB3JABEBAAG0GlVzZXIyIDx1c2VyMjFA
|
||||||
|
ZXhhbXBsZS5jb20+iQFUBBMBCAA+FiEEPOLHOjPSO42DWM57+r85c5/h6ScFAlmG
|
||||||
|
WN4CGwMFCQPCZwAFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQ+r85c5/h6Sfx
|
||||||
|
Lgf/dq64NBV8+X9an3seaLxePRviva48e4K67/wV/JxtXNO5Z/DhMGz5kHXCsG9D
|
||||||
|
CXuWYO8ehlTjEnMZ6qqdDnY+H6bQsb2OS5oPn4RwpPXslAjEKtojPAr0dDsMS2DB
|
||||||
|
dUuIm1AoOnewOVO0OFRf1EqX1bivxnN0FVMcO0m8AczfnKDaGb0y/qg/Y9JAsKqp
|
||||||
|
j5pZNMWUkntRtGySeJ4CVJMmkVKJAHsa1Qj6MKdFeid4h4y94cBJ4ZdyBxNdpQOx
|
||||||
|
ydf0doicovfeqGNO4oWzsGP4RBK2CqGPCUT+EFl20jPvMkKwOjxgqc8p0z3b2UT9
|
||||||
|
+9bnmCGHgF/fW1HJ3iKmfFPqnLkBDQRZhljeAQgA5AirU/NJGgm19ZJYFOiHftjS
|
||||||
|
azbrPxGeD3cSqmvDPIMc1DNZGfQV5D4EVumnVbQBtL6xHFoGKz9KisUMbe4a/X2J
|
||||||
|
S8JmIphQWG0vMJX1DaZIzr2gT71MnPD7JMGsSUCh5dIKpTNTZX4w+oGPGOu0/UlL
|
||||||
|
x0448AryKwp30J2p6D4GeI0nb03n35S2lTOpnHDn1wj7Jl/8LS2fdFOdNaNHXSZe
|
||||||
|
twdSwJKhyBEiScgeHBDyKqo8zWkYoSb9eA2HiYlbVaiNtp24KP1mIEpiUdrRjWno
|
||||||
|
zauYSZGHZlOFMgF4dKWuetPiuH9m7UYZGKyMLfQ9vYFb+xcPh2bLCQHJ1OEmMQAR
|
||||||
|
AQABiQE8BBgBCAAmFiEEPOLHOjPSO42DWM57+r85c5/h6ScFAlmGWN4CGwwFCQPC
|
||||||
|
ZwAACgkQ+r85c5/h6Sfjfwf+O4WEjRdvPJLxNy7mfAGoAqDMHIwyH/tVzYgyVhnG
|
||||||
|
h/+cfRxJbGc3rpjYdr8dmvghzjEAout8uibPWaIqs63RCAPGPqgWLfxNO5c8+y8V
|
||||||
|
LZMVOTV26l2olkkdBWAuhLqKTNh6TiQva03yhOgHWj4XDvFfxICWPFXVd6t5ELpD
|
||||||
|
iApGu1OAj8JfhmzbG03Yzx+Ku7bWDxMonx3V/IDEu5LS5zrboHYDKCA53bXXghoi
|
||||||
|
Aceqql+PKrDwEjoY4bptwMHLmcjGjdCQ//Qx1neho7nZcS7xjTucY8gQuulwCyXF
|
||||||
|
y6wM+wMz8dunIG9gw4+Re6c4Rz9tX1kzxLrU7Pl21tMqfg==
|
||||||
|
=0N/9
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----`)
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ref: refs/heads/master
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[core]
|
||||||
|
repositoryformatversion = 0
|
||||||
|
filemode = true
|
||||||
|
bare = true
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Unnamed repository; edit this file 'description' to name the repository.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to check the commit log message taken by
|
||||||
|
# applypatch from an e-mail message.
|
||||||
|
#
|
||||||
|
# The hook should exit with non-zero status after issuing an
|
||||||
|
# appropriate message if it wants to stop the commit. The hook is
|
||||||
|
# allowed to edit the commit message file.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "applypatch-msg".
|
||||||
|
|
||||||
|
. git-sh-setup
|
||||||
|
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||||
|
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||||
|
:
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to check the commit log message.
|
||||||
|
# Called by "git commit" with one argument, the name of the file
|
||||||
|
# that has the commit message. The hook should exit with non-zero
|
||||||
|
# status after issuing an appropriate message if it wants to stop the
|
||||||
|
# commit. The hook is allowed to edit the commit message file.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "commit-msg".
|
||||||
|
|
||||||
|
# Uncomment the below to add a Signed-off-by line to the message.
|
||||||
|
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||||
|
# hook is more suited to it.
|
||||||
|
#
|
||||||
|
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||||
|
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||||
|
|
||||||
|
# This example catches duplicate Signed-off-by lines.
|
||||||
|
|
||||||
|
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||||
|
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||||
|
echo >&2 Duplicate Signed-off-by lines.
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to prepare a packed repository for use over
|
||||||
|
# dumb transports.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "post-update".
|
||||||
|
|
||||||
|
exec git update-server-info
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to verify what is about to be committed
|
||||||
|
# by applypatch from an e-mail message.
|
||||||
|
#
|
||||||
|
# The hook should exit with non-zero status after issuing an
|
||||||
|
# appropriate message if it wants to stop the commit.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "pre-applypatch".
|
||||||
|
|
||||||
|
. git-sh-setup
|
||||||
|
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||||
|
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||||
|
:
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to verify what is about to be committed.
|
||||||
|
# Called by "git commit" with no arguments. The hook should
|
||||||
|
# exit with non-zero status after issuing an appropriate message if
|
||||||
|
# it wants to stop the commit.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "pre-commit".
|
||||||
|
|
||||||
|
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
against=HEAD
|
||||||
|
else
|
||||||
|
# Initial commit: diff against an empty tree object
|
||||||
|
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If you want to allow non-ASCII filenames set this variable to true.
|
||||||
|
allownonascii=$(git config --bool hooks.allownonascii)
|
||||||
|
|
||||||
|
# Redirect output to stderr.
|
||||||
|
exec 1>&2
|
||||||
|
|
||||||
|
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||||
|
# them from being added to the repository. We exploit the fact that the
|
||||||
|
# printable range starts at the space character and ends with tilde.
|
||||||
|
if [ "$allownonascii" != "true" ] &&
|
||||||
|
# Note that the use of brackets around a tr range is ok here, (it's
|
||||||
|
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||||
|
# the square bracket bytes happen to fall in the designated range.
|
||||||
|
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||||
|
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||||
|
then
|
||||||
|
cat <<\EOF
|
||||||
|
Error: Attempt to add a non-ASCII file name.
|
||||||
|
|
||||||
|
This can cause problems if you want to work with people on other platforms.
|
||||||
|
|
||||||
|
To be portable it is advisable to rename the file.
|
||||||
|
|
||||||
|
If you know what you are doing you can disable this check using:
|
||||||
|
|
||||||
|
git config hooks.allownonascii true
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If there are whitespace errors, print the offending file names and fail.
|
||||||
|
exec git diff-index --check --cached $against --
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# An example hook script to verify what is about to be pushed. Called by "git
|
||||||
|
# push" after it has checked the remote status, but before anything has been
|
||||||
|
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||||
|
#
|
||||||
|
# This hook is called with the following parameters:
|
||||||
|
#
|
||||||
|
# $1 -- Name of the remote to which the push is being done
|
||||||
|
# $2 -- URL to which the push is being done
|
||||||
|
#
|
||||||
|
# If pushing without using a named remote those arguments will be equal.
|
||||||
|
#
|
||||||
|
# Information about the commits which are being pushed is supplied as lines to
|
||||||
|
# the standard input in the form:
|
||||||
|
#
|
||||||
|
# <local ref> <local sha1> <remote ref> <remote sha1>
|
||||||
|
#
|
||||||
|
# This sample shows how to prevent push of commits where the log message starts
|
||||||
|
# with "WIP" (work in progress).
|
||||||
|
|
||||||
|
remote="$1"
|
||||||
|
url="$2"
|
||||||
|
|
||||||
|
z40=0000000000000000000000000000000000000000
|
||||||
|
|
||||||
|
while read local_ref local_sha remote_ref remote_sha
|
||||||
|
do
|
||||||
|
if [ "$local_sha" = $z40 ]
|
||||||
|
then
|
||||||
|
# Handle delete
|
||||||
|
:
|
||||||
|
else
|
||||||
|
if [ "$remote_sha" = $z40 ]
|
||||||
|
then
|
||||||
|
# New branch, examine all commits
|
||||||
|
range="$local_sha"
|
||||||
|
else
|
||||||
|
# Update to existing branch, examine new commits
|
||||||
|
range="$remote_sha..$local_sha"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for WIP commit
|
||||||
|
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
|
||||||
|
if [ -n "$commit" ]
|
||||||
|
then
|
||||||
|
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||||
|
#
|
||||||
|
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||||
|
# its job, and can prevent the command from running by exiting with
|
||||||
|
# non-zero status.
|
||||||
|
#
|
||||||
|
# The hook is called with the following parameters:
|
||||||
|
#
|
||||||
|
# $1 -- the upstream the series was forked from.
|
||||||
|
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||||
|
#
|
||||||
|
# This sample shows how to prevent topic branches that are already
|
||||||
|
# merged to 'next' branch from getting rebased, because allowing it
|
||||||
|
# would result in rebasing already published history.
|
||||||
|
|
||||||
|
publish=next
|
||||||
|
basebranch="$1"
|
||||||
|
if test "$#" = 2
|
||||||
|
then
|
||||||
|
topic="refs/heads/$2"
|
||||||
|
else
|
||||||
|
topic=`git symbolic-ref HEAD` ||
|
||||||
|
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$topic" in
|
||||||
|
refs/heads/??/*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 0 ;# we do not interrupt others.
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Now we are dealing with a topic branch being rebased
|
||||||
|
# on top of master. Is it OK to rebase it?
|
||||||
|
|
||||||
|
# Does the topic really exist?
|
||||||
|
git show-ref -q "$topic" || {
|
||||||
|
echo >&2 "No such branch $topic"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Is topic fully merged to master?
|
||||||
|
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||||
|
if test -z "$not_in_master"
|
||||||
|
then
|
||||||
|
echo >&2 "$topic is fully merged to master; better remove it."
|
||||||
|
exit 1 ;# we could allow it, but there is no point.
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||||
|
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||||
|
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||||
|
if test "$only_next_1" = "$only_next_2"
|
||||||
|
then
|
||||||
|
not_in_topic=`git rev-list "^$topic" master`
|
||||||
|
if test -z "$not_in_topic"
|
||||||
|
then
|
||||||
|
echo >&2 "$topic is already up-to-date with master"
|
||||||
|
exit 1 ;# we could allow it, but there is no point.
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||||
|
/usr/bin/perl -e '
|
||||||
|
my $topic = $ARGV[0];
|
||||||
|
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||||
|
my (%not_in_next) = map {
|
||||||
|
/^([0-9a-f]+) /;
|
||||||
|
($1 => 1);
|
||||||
|
} split(/\n/, $ARGV[1]);
|
||||||
|
for my $elem (map {
|
||||||
|
/^([0-9a-f]+) (.*)$/;
|
||||||
|
[$1 => $2];
|
||||||
|
} split(/\n/, $ARGV[2])) {
|
||||||
|
if (!exists $not_in_next{$elem->[0]}) {
|
||||||
|
if ($msg) {
|
||||||
|
print STDERR $msg;
|
||||||
|
undef $msg;
|
||||||
|
}
|
||||||
|
print STDERR " $elem->[1]\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$topic" "$not_in_next" "$not_in_master"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
This sample hook safeguards topic branches that have been
|
||||||
|
published from being rewound.
|
||||||
|
|
||||||
|
The workflow assumed here is:
|
||||||
|
|
||||||
|
* Once a topic branch forks from "master", "master" is never
|
||||||
|
merged into it again (either directly or indirectly).
|
||||||
|
|
||||||
|
* Once a topic branch is fully cooked and merged into "master",
|
||||||
|
it is deleted. If you need to build on top of it to correct
|
||||||
|
earlier mistakes, a new topic branch is created by forking at
|
||||||
|
the tip of the "master". This is not strictly necessary, but
|
||||||
|
it makes it easier to keep your history simple.
|
||||||
|
|
||||||
|
* Whenever you need to test or publish your changes to topic
|
||||||
|
branches, merge them into "next" branch.
|
||||||
|
|
||||||
|
The script, being an example, hardcodes the publish branch name
|
||||||
|
to be "next", but it is trivial to make it configurable via
|
||||||
|
$GIT_DIR/config mechanism.
|
||||||
|
|
||||||
|
With this workflow, you would want to know:
|
||||||
|
|
||||||
|
(1) ... if a topic branch has ever been merged to "next". Young
|
||||||
|
topic branches can have stupid mistakes you would rather
|
||||||
|
clean up before publishing, and things that have not been
|
||||||
|
merged into other branches can be easily rebased without
|
||||||
|
affecting other people. But once it is published, you would
|
||||||
|
not want to rewind it.
|
||||||
|
|
||||||
|
(2) ... if a topic branch has been fully merged to "master".
|
||||||
|
Then you can delete it. More importantly, you should not
|
||||||
|
build on top of it -- other people may already want to
|
||||||
|
change things related to the topic as patches against your
|
||||||
|
"master", so if you need further changes, it is better to
|
||||||
|
fork the topic (perhaps with the same name) afresh from the
|
||||||
|
tip of "master".
|
||||||
|
|
||||||
|
Let's look at this example:
|
||||||
|
|
||||||
|
o---o---o---o---o---o---o---o---o---o "next"
|
||||||
|
/ / / /
|
||||||
|
/ a---a---b A / /
|
||||||
|
/ / / /
|
||||||
|
/ / c---c---c---c B /
|
||||||
|
/ / / \ /
|
||||||
|
/ / / b---b C \ /
|
||||||
|
/ / / / \ /
|
||||||
|
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||||
|
|
||||||
|
|
||||||
|
A, B and C are topic branches.
|
||||||
|
|
||||||
|
* A has one fix since it was merged up to "next".
|
||||||
|
|
||||||
|
* B has finished. It has been fully merged up to "master" and "next",
|
||||||
|
and is ready to be deleted.
|
||||||
|
|
||||||
|
* C has not merged to "next" at all.
|
||||||
|
|
||||||
|
We would want to allow C to be rebased, refuse A, and encourage
|
||||||
|
B to be deleted.
|
||||||
|
|
||||||
|
To compute (1):
|
||||||
|
|
||||||
|
git rev-list ^master ^topic next
|
||||||
|
git rev-list ^master next
|
||||||
|
|
||||||
|
if these match, topic has not merged in next at all.
|
||||||
|
|
||||||
|
To compute (2):
|
||||||
|
|
||||||
|
git rev-list master..topic
|
||||||
|
|
||||||
|
if this is empty, it is fully merged to "master".
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to make use of push options.
|
||||||
|
# The example simply echoes all push options that start with 'echoback='
|
||||||
|
# and rejects all pushes when the "reject" push option is used.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "pre-receive".
|
||||||
|
|
||||||
|
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||||
|
then
|
||||||
|
i=0
|
||||||
|
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||||
|
do
|
||||||
|
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||||
|
case "$value" in
|
||||||
|
echoback=*)
|
||||||
|
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||||
|
;;
|
||||||
|
reject)
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
fi
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to prepare the commit log message.
|
||||||
|
# Called by "git commit" with the name of the file that has the
|
||||||
|
# commit message, followed by the description of the commit
|
||||||
|
# message's source. The hook's purpose is to edit the commit
|
||||||
|
# message file. If the hook fails with a non-zero status,
|
||||||
|
# the commit is aborted.
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||||
|
|
||||||
|
# This hook includes three examples. The first comments out the
|
||||||
|
# "Conflicts:" part of a merge commit.
|
||||||
|
#
|
||||||
|
# The second includes the output of "git diff --name-status -r"
|
||||||
|
# into the message, just before the "git status" output. It is
|
||||||
|
# commented because it doesn't cope with --amend or with squashed
|
||||||
|
# commits.
|
||||||
|
#
|
||||||
|
# The third example adds a Signed-off-by line to the message, that can
|
||||||
|
# still be edited. This is rarely a good idea.
|
||||||
|
|
||||||
|
case "$2,$3" in
|
||||||
|
merge,)
|
||||||
|
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
|
||||||
|
|
||||||
|
# ,|template,)
|
||||||
|
# /usr/bin/perl -i.bak -pe '
|
||||||
|
# print "\n" . `git diff --cached --name-status -r`
|
||||||
|
# if /^#/ && $first++ == 0' "$1" ;;
|
||||||
|
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||||
|
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# An example hook script to block unannotated tags from entering.
|
||||||
|
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||||
|
#
|
||||||
|
# To enable this hook, rename this file to "update".
|
||||||
|
#
|
||||||
|
# Config
|
||||||
|
# ------
|
||||||
|
# hooks.allowunannotated
|
||||||
|
# This boolean sets whether unannotated tags will be allowed into the
|
||||||
|
# repository. By default they won't be.
|
||||||
|
# hooks.allowdeletetag
|
||||||
|
# This boolean sets whether deleting tags will be allowed in the
|
||||||
|
# repository. By default they won't be.
|
||||||
|
# hooks.allowmodifytag
|
||||||
|
# This boolean sets whether a tag may be modified after creation. By default
|
||||||
|
# it won't be.
|
||||||
|
# hooks.allowdeletebranch
|
||||||
|
# This boolean sets whether deleting branches will be allowed in the
|
||||||
|
# repository. By default they won't be.
|
||||||
|
# hooks.denycreatebranch
|
||||||
|
# This boolean sets whether remotely creating branches will be denied
|
||||||
|
# in the repository. By default this is allowed.
|
||||||
|
#
|
||||||
|
|
||||||
|
# --- Command line
|
||||||
|
refname="$1"
|
||||||
|
oldrev="$2"
|
||||||
|
newrev="$3"
|
||||||
|
|
||||||
|
# --- Safety check
|
||||||
|
if [ -z "$GIT_DIR" ]; then
|
||||||
|
echo "Don't run this script from the command line." >&2
|
||||||
|
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||||
|
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||||
|
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Config
|
||||||
|
allowunannotated=$(git config --bool hooks.allowunannotated)
|
||||||
|
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
|
||||||
|
denycreatebranch=$(git config --bool hooks.denycreatebranch)
|
||||||
|
allowdeletetag=$(git config --bool hooks.allowdeletetag)
|
||||||
|
allowmodifytag=$(git config --bool hooks.allowmodifytag)
|
||||||
|
|
||||||
|
# check for no description
|
||||||
|
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||||
|
case "$projectdesc" in
|
||||||
|
"Unnamed repository"* | "")
|
||||||
|
echo "*** Project description file hasn't been set" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# --- Check types
|
||||||
|
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||||
|
zero="0000000000000000000000000000000000000000"
|
||||||
|
if [ "$newrev" = "$zero" ]; then
|
||||||
|
newrev_type=delete
|
||||||
|
else
|
||||||
|
newrev_type=$(git cat-file -t $newrev)
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$refname","$newrev_type" in
|
||||||
|
refs/tags/*,commit)
|
||||||
|
# un-annotated tag
|
||||||
|
short_refname=${refname##refs/tags/}
|
||||||
|
if [ "$allowunannotated" != "true" ]; then
|
||||||
|
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||||
|
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
refs/tags/*,delete)
|
||||||
|
# delete tag
|
||||||
|
if [ "$allowdeletetag" != "true" ]; then
|
||||||
|
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
refs/tags/*,tag)
|
||||||
|
# annotated tag
|
||||||
|
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo "*** Tag '$refname' already exists." >&2
|
||||||
|
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
refs/heads/*,commit)
|
||||||
|
# branch
|
||||||
|
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||||
|
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
refs/heads/*,delete)
|
||||||
|
# delete branch
|
||||||
|
if [ "$allowdeletebranch" != "true" ]; then
|
||||||
|
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
refs/remotes/*,commit)
|
||||||
|
# tracking branch
|
||||||
|
;;
|
||||||
|
refs/remotes/*,delete)
|
||||||
|
# delete tracking branch
|
||||||
|
if [ "$allowdeletebranch" != "true" ]; then
|
||||||
|
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Anything else (is there anything else?)
|
||||||
|
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# --- Finished
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# git ls-files --others --exclude-from=.git/info/exclude
|
||||||
|
# Lines that start with '#' are comments.
|
||||||
|
# For a project mostly in C, the following would be a good set of
|
||||||
|
# exclude patterns (uncomment them if you want to use them):
|
||||||
|
# *.[oa]
|
||||||
|
# *~
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
x+)JMU06g040031Q(JML<4D>M<EFBFBD><4D>MaXbR<62><52>10<31>-&<26><>C<EFBFBD><43><EFBFBD>˒<EFBFBD><CB92>=<3D>,
|
||||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
|||||||
|
x<01><>Q
|
||||||
|
B!E<>v<15><1F><>O'!<21>M<EFBFBD><4D>Q<EFBFBD>׃<EFBFBD><D783><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><02><><EFBFBD><0B><>TKY:v<><76><EFBFBD>N6<4E><36><EFBFBD><EFBFBD>b f<><66><EFBFBD><EFBFBD><EFBFBD>&<26><>19<31><39><EFBFBD>ho<>V\Wi<08><>yqy<71><79><EFBFBD>j9<6A>q<1A><>F<1B><0F>j<EFBFBD><6A><EFBFBD><EFBFBD>?ٟ<><D99F>Z3<5A><33><EFBFBD><EFBFBD><0C><05>*S6#
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
f27c2b2b03dcab38beaf89b0ab4ff61f6de63441
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
27566bd5738fc8b4e3fef3c5e72cce608537bd95
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
69554a64c1e6030f051e5c3f94bfbd773cd6a324
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
69554a64c1e6030f051e5c3f94bfbd773cd6a324
|
||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import "fmt"
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ErrNameReserved represents a "reserved name" error.
|
// ErrNameReserved represents a "reserved name" error.
|
||||||
type ErrNameReserved struct {
|
type ErrNameReserved struct {
|
||||||
@@ -260,19 +258,19 @@ func (err ErrKeyNameAlreadyUsed) Error() string {
|
|||||||
return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
|
return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrGPGEmailNotFound represents a "ErrGPGEmailNotFound" kind of error.
|
// ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
|
||||||
type ErrGPGEmailNotFound struct {
|
type ErrGPGNoEmailFound struct {
|
||||||
Email string
|
FailedEmails []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsErrGPGEmailNotFound checks if an error is a ErrGPGEmailNotFound.
|
// IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.
|
||||||
func IsErrGPGEmailNotFound(err error) bool {
|
func IsErrGPGNoEmailFound(err error) bool {
|
||||||
_, ok := err.(ErrGPGEmailNotFound)
|
_, ok := err.(ErrGPGNoEmailFound)
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err ErrGPGEmailNotFound) Error() string {
|
func (err ErrGPGNoEmailFound) Error() string {
|
||||||
return fmt.Sprintf("failed to found email or is not confirmed : %s", err.Email)
|
return fmt.Sprintf("none of the emails attached to the GPG key could be found: %v", err.FailedEmails)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.
|
// ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.
|
||||||
|
|||||||
@@ -176,3 +176,15 @@
|
|||||||
lower_name: repo15
|
lower_name: repo15
|
||||||
name: repo15
|
name: repo15
|
||||||
is_bare: true
|
is_bare: true
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 16
|
||||||
|
owner_id: 2
|
||||||
|
lower_name: repo16
|
||||||
|
name: repo16
|
||||||
|
is_private: true
|
||||||
|
num_issues: 0
|
||||||
|
num_closed_issues: 0
|
||||||
|
num_pulls: 0
|
||||||
|
num_closed_pulls: 0
|
||||||
|
num_watches: 0
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
is_admin: false
|
is_admin: false
|
||||||
avatar: avatar2
|
avatar: avatar2
|
||||||
avatar_email: user2@example.com
|
avatar_email: user2@example.com
|
||||||
num_repos: 3
|
num_repos: 4
|
||||||
num_stars: 2
|
num_stars: 2
|
||||||
num_followers: 2
|
num_followers: 2
|
||||||
num_following: 1
|
num_following: 1
|
||||||
|
|||||||
@@ -208,21 +208,27 @@ func parseGPGKey(ownerID int64, e *openpgp.Entity) (*GPGKey, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
emails := make([]*EmailAddress, len(e.Identities))
|
|
||||||
n := 0
|
emails := make([]*EmailAddress, 0, len(e.Identities))
|
||||||
for _, ident := range e.Identities {
|
for _, ident := range e.Identities {
|
||||||
email := strings.ToLower(strings.TrimSpace(ident.UserId.Email))
|
email := strings.ToLower(strings.TrimSpace(ident.UserId.Email))
|
||||||
for _, e := range userEmails {
|
for _, e := range userEmails {
|
||||||
if e.Email == email && e.IsActivated {
|
if e.Email == email {
|
||||||
emails[n] = e
|
emails = append(emails, e)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if emails[n] == nil {
|
|
||||||
return nil, ErrGPGEmailNotFound{ident.UserId.Email}
|
|
||||||
}
|
|
||||||
n++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//In the case no email as been found
|
||||||
|
if len(emails) == 0 {
|
||||||
|
failedEmails := make([]string, 0, len(e.Identities))
|
||||||
|
for _, ident := range e.Identities {
|
||||||
|
failedEmails = append(failedEmails, ident.UserId.Email)
|
||||||
|
}
|
||||||
|
return nil, ErrGPGNoEmailFound{failedEmails}
|
||||||
|
}
|
||||||
|
|
||||||
content, err := base64EncPubKey(pubkey)
|
content, err := base64EncPubKey(pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -376,8 +382,8 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Find Committer account
|
//Find Committer account
|
||||||
committer, err := GetUserByEmail(c.Committer.Email)
|
committer, err := GetUserByEmail(c.Committer.Email) //This find the user by primary email or activated email so commit will not be valid if email is not
|
||||||
if err != nil { //Skipping not user for commiter
|
if err != nil { //Skipping not user for commiter
|
||||||
log.Error(3, "NoCommitterAccount: %v", err)
|
log.Error(3, "NoCommitterAccount: %v", err)
|
||||||
return &CommitVerification{
|
return &CommitVerification{
|
||||||
Verified: false,
|
Verified: false,
|
||||||
@@ -395,6 +401,19 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
|
//Pre-check (& optimization) that emails attached to key can be attached to the commiter email and can validate
|
||||||
|
canValidate := false
|
||||||
|
lowerCommiterEmail := strings.ToLower(c.Committer.Email)
|
||||||
|
for _, e := range k.Emails {
|
||||||
|
if e.IsActivated && strings.ToLower(e.Email) == lowerCommiterEmail {
|
||||||
|
canValidate = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !canValidate {
|
||||||
|
continue //Skip this key
|
||||||
|
}
|
||||||
|
|
||||||
//Generating hash of commit
|
//Generating hash of commit
|
||||||
hash, err := populateHash(sig.Hash, []byte(c.Signature.Payload))
|
hash, err := populateHash(sig.Hash, []byte(c.Signature.Payload))
|
||||||
if err != nil { //Skipping ailed to generate hash
|
if err != nil { //Skipping ailed to generate hash
|
||||||
|
|||||||
@@ -613,6 +613,7 @@ func findComments(e Engine, opts FindCommentsOptions) ([]*Comment, error) {
|
|||||||
}
|
}
|
||||||
return comments, sess.
|
return comments, sess.
|
||||||
Asc("comment.created_unix").
|
Asc("comment.created_unix").
|
||||||
|
Asc("comment.id").
|
||||||
Find(&comments)
|
Find(&comments)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ func composeIssueCommentMessage(issue *Issue, doer *User, comment *Comment, tplN
|
|||||||
log.Error(3, "Template: %v", err)
|
log.Error(3, "Template: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := mailer.NewMessageFrom(tos, fmt.Sprintf(`"%s" <%s>`, doer.DisplayName(), setting.MailService.FromEmail), subject, content.String())
|
msg := mailer.NewMessageFrom(tos, doer.DisplayName(), setting.MailService.FromEmail, subject, content.String())
|
||||||
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
|
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/git"
|
"code.gitea.io/git"
|
||||||
|
|
||||||
@@ -119,11 +120,24 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Commit: %v", err)
|
return fmt.Errorf("Commit: %v", err)
|
||||||
}
|
}
|
||||||
tagCreatedUnix := commit.Author.When.Unix()
|
|
||||||
|
|
||||||
author, err := GetUserByEmail(commit.Author.Email)
|
sig := tag.Tagger
|
||||||
if err != nil && !IsErrUserNotExist(err) {
|
if sig == nil {
|
||||||
return fmt.Errorf("GetUserByEmail: %v", err)
|
sig = commit.Author
|
||||||
|
}
|
||||||
|
if sig == nil {
|
||||||
|
sig = commit.Committer
|
||||||
|
}
|
||||||
|
|
||||||
|
var author *User
|
||||||
|
var createdAt = time.Unix(1, 0)
|
||||||
|
|
||||||
|
if sig != nil {
|
||||||
|
author, err = GetUserByEmail(sig.Email)
|
||||||
|
if err != nil && !IsErrUserNotExist(err) {
|
||||||
|
return fmt.Errorf("GetUserByEmail: %v", err)
|
||||||
|
}
|
||||||
|
createdAt = sig.When
|
||||||
}
|
}
|
||||||
|
|
||||||
commitsCount, err := commit.CommitsCount()
|
commitsCount, err := commit.CommitsCount()
|
||||||
@@ -144,7 +158,8 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
|
|||||||
IsDraft: false,
|
IsDraft: false,
|
||||||
IsPrerelease: false,
|
IsPrerelease: false,
|
||||||
IsTag: true,
|
IsTag: true,
|
||||||
CreatedUnix: tagCreatedUnix,
|
Created: createdAt,
|
||||||
|
CreatedUnix: createdAt.Unix(),
|
||||||
}
|
}
|
||||||
if author != nil {
|
if author != nil {
|
||||||
rel.PublisherID = author.ID
|
rel.PublisherID = author.ID
|
||||||
@@ -155,7 +170,8 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rel.Sha1 = commit.ID.String()
|
rel.Sha1 = commit.ID.String()
|
||||||
rel.CreatedUnix = tagCreatedUnix
|
rel.Created = createdAt
|
||||||
|
rel.CreatedUnix = createdAt.Unix()
|
||||||
rel.NumCommits = commitsCount
|
rel.NumCommits = commitsCount
|
||||||
rel.IsDraft = false
|
rel.IsDraft = false
|
||||||
if rel.IsTag && author != nil {
|
if rel.IsTag && author != nil {
|
||||||
|
|||||||
@@ -1205,6 +1205,9 @@ type UserCommit struct {
|
|||||||
|
|
||||||
// ValidateCommitWithEmail check if author's e-mail of commit is corresponding to a user.
|
// ValidateCommitWithEmail check if author's e-mail of commit is corresponding to a user.
|
||||||
func ValidateCommitWithEmail(c *git.Commit) *User {
|
func ValidateCommitWithEmail(c *git.Commit) *User {
|
||||||
|
if c.Author == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
u, err := GetUserByEmail(c.Author.Email)
|
u, err := GetUserByEmail(c.Author.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -1223,11 +1226,15 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
|
|||||||
for e != nil {
|
for e != nil {
|
||||||
c := e.Value.(*git.Commit)
|
c := e.Value.(*git.Commit)
|
||||||
|
|
||||||
if v, ok := emails[c.Author.Email]; !ok {
|
if c.Author != nil {
|
||||||
u, _ = GetUserByEmail(c.Author.Email)
|
if v, ok := emails[c.Author.Email]; !ok {
|
||||||
emails[c.Author.Email] = u
|
u, _ = GetUserByEmail(c.Author.Email)
|
||||||
|
emails[c.Author.Email] = u
|
||||||
|
} else {
|
||||||
|
u = v
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
u = v
|
u = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
newCommits.PushBack(UserCommit{
|
newCommits.PushBack(UserCommit{
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ type Message struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewMessageFrom creates new mail message object with custom From header.
|
// NewMessageFrom creates new mail message object with custom From header.
|
||||||
func NewMessageFrom(to []string, from, subject, body string) *Message {
|
func NewMessageFrom(to []string, fromDisplayName, fromAddress, subject, body string) *Message {
|
||||||
log.Trace("NewMessageFrom (body):\n%s", body)
|
log.Trace("NewMessageFrom (body):\n%s", body)
|
||||||
|
|
||||||
msg := gomail.NewMessage()
|
msg := gomail.NewMessage()
|
||||||
msg.SetHeader("From", from)
|
msg.SetAddressHeader("From", fromAddress, fromDisplayName)
|
||||||
msg.SetHeader("To", to...)
|
msg.SetHeader("To", to...)
|
||||||
msg.SetHeader("Subject", subject)
|
msg.SetHeader("Subject", subject)
|
||||||
msg.SetDateHeader("Date", time.Now())
|
msg.SetDateHeader("Date", time.Now())
|
||||||
@@ -58,7 +58,7 @@ func NewMessageFrom(to []string, from, subject, body string) *Message {
|
|||||||
|
|
||||||
// NewMessage creates new mail message object with default From header.
|
// NewMessage creates new mail message object with default From header.
|
||||||
func NewMessage(to []string, subject, body string) *Message {
|
func NewMessage(to []string, subject, body string) *Message {
|
||||||
return NewMessageFrom(to, setting.MailService.From, subject, body)
|
return NewMessageFrom(to, setting.MailService.FromName, setting.MailService.FromEmail, subject, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
type loginAuth struct {
|
type loginAuth struct {
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ var (
|
|||||||
}{
|
}{
|
||||||
DisableDiffHighlight: false,
|
DisableDiffHighlight: false,
|
||||||
MaxGitDiffLines: 1000,
|
MaxGitDiffLines: 1000,
|
||||||
MaxGitDiffLineCharacters: 500,
|
MaxGitDiffLineCharacters: 5000,
|
||||||
MaxGitDiffFiles: 100,
|
MaxGitDiffFiles: 100,
|
||||||
GCArgs: []string{},
|
GCArgs: []string{},
|
||||||
Timeout: struct {
|
Timeout: struct {
|
||||||
@@ -1281,6 +1281,7 @@ type Mailer struct {
|
|||||||
QueueLength int
|
QueueLength int
|
||||||
Name string
|
Name string
|
||||||
From string
|
From string
|
||||||
|
FromName string
|
||||||
FromEmail string
|
FromEmail string
|
||||||
SendAsPlainText bool
|
SendAsPlainText bool
|
||||||
|
|
||||||
@@ -1339,6 +1340,7 @@ func newMailService() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
|
log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
|
||||||
}
|
}
|
||||||
|
MailService.FromName = parsed.Name
|
||||||
MailService.FromEmail = parsed.Address
|
MailService.FromEmail = parsed.Address
|
||||||
|
|
||||||
log.Info("Mail Service Enabled")
|
log.Info("Mail Service Enabled")
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ add_new_gpg_key = Add GPG Key
|
|||||||
ssh_key_been_used = This public key has already been used.
|
ssh_key_been_used = This public key has already been used.
|
||||||
ssh_key_name_used = A public key with same name already exists.
|
ssh_key_name_used = A public key with same name already exists.
|
||||||
gpg_key_id_used = A public GPG key with same id already exists.
|
gpg_key_id_used = A public GPG key with same id already exists.
|
||||||
gpg_key_email_not_found = The email attached to the GPG key couldn't be found or is not confirmed yet: %s
|
gpg_no_key_email_found = None of the emails attached to the GPG key could be found.
|
||||||
subkeys = Subkeys
|
subkeys = Subkeys
|
||||||
key_id = Key ID
|
key_id = Key ID
|
||||||
key_name = Key Name
|
key_name = Key Name
|
||||||
|
|||||||
@@ -1456,7 +1456,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
// Emojify
|
// Emojify
|
||||||
emojify.setConfig({
|
emojify.setConfig({
|
||||||
img_dir: suburl + '/plugins/emojify/images',
|
img_dir: suburl + '/vendor/plugins/emojify/images',
|
||||||
ignore_emoticons: true
|
ignore_emoticons: true
|
||||||
});
|
});
|
||||||
var hasEmoji = document.getElementsByClassName('has-emoji');
|
var hasEmoji = document.getElementsByClassName('has-emoji');
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ package user
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
|
||||||
|
|
||||||
api "code.gitea.io/sdk/gitea"
|
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
|
"code.gitea.io/gitea/modules/markdown"
|
||||||
|
api "code.gitea.io/sdk/gitea"
|
||||||
|
|
||||||
|
"github.com/Unknwon/com"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Search search users
|
// Search search users
|
||||||
@@ -50,7 +50,7 @@ func Search(ctx *context.APIContext) {
|
|||||||
ID: users[i].ID,
|
ID: users[i].ID,
|
||||||
UserName: users[i].Name,
|
UserName: users[i].Name,
|
||||||
AvatarURL: users[i].AvatarLink(),
|
AvatarURL: users[i].AvatarLink(),
|
||||||
FullName: users[i].FullName,
|
FullName: markdown.Sanitize(users[i].FullName),
|
||||||
}
|
}
|
||||||
if ctx.IsSigned {
|
if ctx.IsSigned {
|
||||||
results[i].Email = users[i].Email
|
results[i].Email = users[i].Email
|
||||||
|
|||||||
@@ -378,9 +378,9 @@ func SettingsKeysPost(ctx *context.Context, form auth.AddKeyForm) {
|
|||||||
case models.IsErrGPGKeyIDAlreadyUsed(err):
|
case models.IsErrGPGKeyIDAlreadyUsed(err):
|
||||||
ctx.Data["Err_Content"] = true
|
ctx.Data["Err_Content"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("settings.gpg_key_id_used"), tplSettingsKeys, &form)
|
ctx.RenderWithErr(ctx.Tr("settings.gpg_key_id_used"), tplSettingsKeys, &form)
|
||||||
case models.IsErrGPGEmailNotFound(err):
|
case models.IsErrGPGNoEmailFound(err):
|
||||||
ctx.Data["Err_Content"] = true
|
ctx.Data["Err_Content"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("settings.gpg_key_email_not_found", err.(models.ErrGPGEmailNotFound).Email), tplSettingsKeys, &form)
|
ctx.RenderWithErr(ctx.Tr("settings.gpg_no_key_email_found"), tplSettingsKeys, &form)
|
||||||
default:
|
default:
|
||||||
ctx.Handle(500, "AddPublicKey", err)
|
ctx.Handle(500, "AddPublicKey", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
<input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="direct" {{if eq .commit_choice "direct"}}checked{{end}}>
|
<input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="direct" {{if eq .commit_choice "direct"}}checked{{end}}>
|
||||||
<label>
|
<label>
|
||||||
<i class="octicon octicon-git-commit" height="16" width="14"></i>
|
<i class="octicon octicon-git-commit" height="16" width="14"></i>
|
||||||
{{.i18n.Tr "repo.editor.commit_directly_to_this_branch" .BranchName | Safe}}
|
{{$branchName := .BranchName | Str2html}}
|
||||||
|
{{.i18n.Tr "repo.editor.commit_directly_to_this_branch" $branchName | Safe}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
{{if .Issue.PullRequest.HasMerged}}
|
{{if .Issue.PullRequest.HasMerged}}
|
||||||
{{ $mergedStr:= TimeSince .Issue.PullRequest.Merged $.Lang }}
|
{{ $mergedStr:= TimeSince .Issue.PullRequest.Merged $.Lang }}
|
||||||
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.Name}}</a>
|
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.Name}}</a>
|
||||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits .HeadTarget .BaseTarget $mergedStr | Safe}}</span>
|
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits .HeadTarget .BaseTarget $mergedStr | Str2html}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a>
|
<a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a>
|
||||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits .HeadTarget .BaseTarget | Str2html}}</span>
|
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits .HeadTarget .BaseTarget | Str2html}}</span>
|
||||||
|
|||||||
@@ -4,14 +4,16 @@
|
|||||||
<th class="four wide">
|
<th class="four wide">
|
||||||
{{if .LatestCommitUser}}
|
{{if .LatestCommitUser}}
|
||||||
<img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" />
|
<img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" />
|
||||||
{{if .LatestCommitUser.FullName}}
|
{{if .LatestCommitUser.FullName}}
|
||||||
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
|
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></a>
|
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" />
|
{{if .LatestCommit.Author}}
|
||||||
<strong>{{.LatestCommit.Author.Name}}</strong>
|
<img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" />
|
||||||
|
<strong>{{.LatestCommit.Author.Name}}</strong>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified }} isVerified {{end}}{{end}}" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}">
|
<a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified }} isVerified {{end}}{{end}}" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}">
|
||||||
{{ShortSha .LatestCommit.ID.String}}
|
{{ShortSha .LatestCommit.ID.String}}
|
||||||
@@ -29,7 +31,7 @@
|
|||||||
</th>
|
</th>
|
||||||
<th class="nine wide">
|
<th class="nine wide">
|
||||||
</th>
|
</th>
|
||||||
<th class="three wide text grey right age">{{TimeSince .LatestCommit.Author.When $.Lang}}</th>
|
<th class="three wide text grey right age">{{if .LatestCommit.Author}}{{TimeSince .LatestCommit.Author.When $.Lang}}{{end}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
2
vendor/code.gitea.io/git/MAINTAINERS
generated
vendored
2
vendor/code.gitea.io/git/MAINTAINERS
generated
vendored
@@ -15,3 +15,5 @@ Thomas Boerger <thomas@webhippie.de> (@tboerger)
|
|||||||
Lauris Bukšis-Haberkorns <lauris@nix.lv> (@lafriks)
|
Lauris Bukšis-Haberkorns <lauris@nix.lv> (@lafriks)
|
||||||
Antoine Girard <sapk@sapk.fr> (@sapk)
|
Antoine Girard <sapk@sapk.fr> (@sapk)
|
||||||
Jonas Östanbäck <jonas.ostanback@gmail.com> (@cez81)
|
Jonas Östanbäck <jonas.ostanback@gmail.com> (@cez81)
|
||||||
|
David Schneiderbauer <dschneiderbauer@gmail.com> (@daviian)
|
||||||
|
Peter Žeby <morlinest@gmail.com> (@morlinest)
|
||||||
|
|||||||
13
vendor/code.gitea.io/git/commit.go
generated
vendored
13
vendor/code.gitea.io/git/commit.go
generated
vendored
@@ -12,8 +12,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mcuadros/go-version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Commit represents a git commit.
|
// Commit represents a git commit.
|
||||||
@@ -160,13 +158,7 @@ func CommitChanges(repoPath string, opts CommitChangesOptions) error {
|
|||||||
|
|
||||||
func commitsCount(repoPath, revision, relpath string) (int64, error) {
|
func commitsCount(repoPath, revision, relpath string) (int64, error) {
|
||||||
var cmd *Command
|
var cmd *Command
|
||||||
isFallback := false
|
cmd = NewCommand("rev-list", "--count")
|
||||||
if version.Compare(gitVersion, "1.8.0", "<") {
|
|
||||||
isFallback = true
|
|
||||||
cmd = NewCommand("log", "--pretty=format:''")
|
|
||||||
} else {
|
|
||||||
cmd = NewCommand("rev-list", "--count")
|
|
||||||
}
|
|
||||||
cmd.AddArguments(revision)
|
cmd.AddArguments(revision)
|
||||||
if len(relpath) > 0 {
|
if len(relpath) > 0 {
|
||||||
cmd.AddArguments("--", relpath)
|
cmd.AddArguments("--", relpath)
|
||||||
@@ -177,9 +169,6 @@ func commitsCount(repoPath, revision, relpath string) (int64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if isFallback {
|
|
||||||
return int64(strings.Count(stdout, "\n")) + 1, nil
|
|
||||||
}
|
|
||||||
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
|
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
vendor/code.gitea.io/git/repo_branch.go
generated
vendored
6
vendor/code.gitea.io/git/repo_branch.go
generated
vendored
@@ -7,8 +7,6 @@ package git
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mcuadros/go-version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// BranchPrefix base dir of the branch information file store on git
|
// BranchPrefix base dir of the branch information file store on git
|
||||||
@@ -56,10 +54,6 @@ func (repo *Repository) GetHEADBranch() (*Branch, error) {
|
|||||||
|
|
||||||
// SetDefaultBranch sets default branch of repository.
|
// SetDefaultBranch sets default branch of repository.
|
||||||
func (repo *Repository) SetDefaultBranch(name string) error {
|
func (repo *Repository) SetDefaultBranch(name string) error {
|
||||||
if version.Compare(gitVersion, "1.7.10", "<") {
|
|
||||||
return ErrUnsupportedVersion{"1.7.10"}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := NewCommand("symbolic-ref", "HEAD", BranchPrefix+name).RunInDir(repo.Path)
|
_, err := NewCommand("symbolic-ref", "HEAD", BranchPrefix+name).RunInDir(repo.Path)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
36
vendor/code.gitea.io/git/repo_commit.go
generated
vendored
36
vendor/code.gitea.io/git/repo_commit.go
generated
vendored
@@ -10,8 +10,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mcuadros/go-version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// getRefCommitID returns the last commit ID string of given reference (branch or tag).
|
// getRefCommitID returns the last commit ID string of given reference (branch or tag).
|
||||||
@@ -248,37 +246,11 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
|
|||||||
|
|
||||||
// CommitsBetween returns a list that contains commits between [last, before).
|
// CommitsBetween returns a list that contains commits between [last, before).
|
||||||
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
|
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
|
||||||
if version.Compare(gitVersion, "1.8.0", ">=") {
|
stdout, err := NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
|
||||||
stdout, err := NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
|
if err != nil {
|
||||||
if err != nil {
|
return nil, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
|
|
||||||
}
|
}
|
||||||
|
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
|
||||||
// Fallback to stupid solution, which iterates all commits of the repository
|
|
||||||
// if before is not an ancestor of last.
|
|
||||||
l := list.New()
|
|
||||||
if last == nil || last.ParentCount() == 0 {
|
|
||||||
return l, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
cur := last
|
|
||||||
for {
|
|
||||||
if cur.ID.Equal(before.ID) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
l.PushBack(cur)
|
|
||||||
if cur.ParentCount() == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
cur, err = cur.Parent(0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return l, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsBetweenIDs return commits between twoe commits
|
// CommitsBetweenIDs return commits between twoe commits
|
||||||
|
|||||||
25
vendor/code.gitea.io/git/signature.go
generated
vendored
25
vendor/code.gitea.io/git/signature.go
generated
vendored
@@ -32,17 +32,22 @@ func newSignatureFromCommitline(line []byte) (_ *Signature, err error) {
|
|||||||
sig.Email = string(line[emailStart+1 : emailEnd])
|
sig.Email = string(line[emailStart+1 : emailEnd])
|
||||||
|
|
||||||
// Check date format.
|
// Check date format.
|
||||||
firstChar := line[emailEnd+2]
|
if len(line) > emailEnd+2 {
|
||||||
if firstChar >= 48 && firstChar <= 57 {
|
firstChar := line[emailEnd+2]
|
||||||
timestop := bytes.IndexByte(line[emailEnd+2:], ' ')
|
if firstChar >= 48 && firstChar <= 57 {
|
||||||
timestring := string(line[emailEnd+2 : emailEnd+2+timestop])
|
timestop := bytes.IndexByte(line[emailEnd+2:], ' ')
|
||||||
seconds, _ := strconv.ParseInt(timestring, 10, 64)
|
timestring := string(line[emailEnd+2 : emailEnd+2+timestop])
|
||||||
sig.When = time.Unix(seconds, 0)
|
seconds, _ := strconv.ParseInt(timestring, 10, 64)
|
||||||
} else {
|
sig.When = time.Unix(seconds, 0)
|
||||||
sig.When, err = time.Parse("Mon Jan _2 15:04:05 2006 -0700", string(line[emailEnd+2:]))
|
} else {
|
||||||
if err != nil {
|
sig.When, err = time.Parse("Mon Jan _2 15:04:05 2006 -0700", string(line[emailEnd+2:]))
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Fall back to unix 0 time
|
||||||
|
sig.When = time.Unix(0, 0)
|
||||||
}
|
}
|
||||||
return sig, nil
|
return sig, nil
|
||||||
}
|
}
|
||||||
|
|||||||
40
vendor/code.gitea.io/git/tree_entry.go
generated
vendored
40
vendor/code.gitea.io/git/tree_entry.go
generated
vendored
@@ -116,35 +116,51 @@ func (te *TreeEntry) GetSubJumpablePathName() string {
|
|||||||
// Entries a list of entry
|
// Entries a list of entry
|
||||||
type Entries []*TreeEntry
|
type Entries []*TreeEntry
|
||||||
|
|
||||||
var sorter = []func(t1, t2 *TreeEntry) bool{
|
type customSortableEntries struct {
|
||||||
func(t1, t2 *TreeEntry) bool {
|
Comparer func(s1, s2 string) bool
|
||||||
|
Entries
|
||||||
|
}
|
||||||
|
|
||||||
|
var sorter = []func(t1, t2 *TreeEntry, cmp func(s1, s2 string) bool) bool{
|
||||||
|
func(t1, t2 *TreeEntry, cmp func(s1, s2 string) bool) bool {
|
||||||
return (t1.IsDir() || t1.IsSubModule()) && !t2.IsDir() && !t2.IsSubModule()
|
return (t1.IsDir() || t1.IsSubModule()) && !t2.IsDir() && !t2.IsSubModule()
|
||||||
},
|
},
|
||||||
func(t1, t2 *TreeEntry) bool {
|
func(t1, t2 *TreeEntry, cmp func(s1, s2 string) bool) bool {
|
||||||
return t1.name < t2.name
|
return cmp(t1.name, t2.name)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tes Entries) Len() int { return len(tes) }
|
func (ctes customSortableEntries) Len() int { return len(ctes.Entries) }
|
||||||
func (tes Entries) Swap(i, j int) { tes[i], tes[j] = tes[j], tes[i] }
|
|
||||||
func (tes Entries) Less(i, j int) bool {
|
func (ctes customSortableEntries) Swap(i, j int) {
|
||||||
t1, t2 := tes[i], tes[j]
|
ctes.Entries[i], ctes.Entries[j] = ctes.Entries[j], ctes.Entries[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctes customSortableEntries) Less(i, j int) bool {
|
||||||
|
t1, t2 := ctes.Entries[i], ctes.Entries[j]
|
||||||
var k int
|
var k int
|
||||||
for k = 0; k < len(sorter)-1; k++ {
|
for k = 0; k < len(sorter)-1; k++ {
|
||||||
s := sorter[k]
|
s := sorter[k]
|
||||||
switch {
|
switch {
|
||||||
case s(t1, t2):
|
case s(t1, t2, ctes.Comparer):
|
||||||
return true
|
return true
|
||||||
case s(t2, t1):
|
case s(t2, t1, ctes.Comparer):
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sorter[k](t1, t2)
|
return sorter[k](t1, t2, ctes.Comparer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort sort the list of entry
|
// Sort sort the list of entry
|
||||||
func (tes Entries) Sort() {
|
func (tes Entries) Sort() {
|
||||||
sort.Sort(tes)
|
sort.Sort(customSortableEntries{func(s1, s2 string) bool {
|
||||||
|
return s1 < s2
|
||||||
|
}, tes})
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomSort customizable string comparing sort entry list
|
||||||
|
func (tes Entries) CustomSort(cmp func(s1, s2 string) bool) {
|
||||||
|
sort.Sort(customSortableEntries{cmp, tes})
|
||||||
}
|
}
|
||||||
|
|
||||||
type commitInfo struct {
|
type commitInfo struct {
|
||||||
|
|||||||
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
@@ -3,10 +3,10 @@
|
|||||||
"ignore": "test appengine",
|
"ignore": "test appengine",
|
||||||
"package": [
|
"package": [
|
||||||
{
|
{
|
||||||
"checksumSHA1": "fR5YDSoG7xYv2aLO23rne95gWps=",
|
"checksumSHA1": "JN/re4+x/hCzMLGHmieUcykVDAg=",
|
||||||
"path": "code.gitea.io/git",
|
"path": "code.gitea.io/git",
|
||||||
"revision": "479f87e5d189e7b8f1fd51dbcd25faa32b632cd2",
|
"revision": "d47b98c44c9a6472e44ab80efe65235e11c6da2a",
|
||||||
"revisionTime": "2017-08-03T00:53:29Z"
|
"revisionTime": "2017-10-23T00:52:09Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Zgp5RqU+20L2p9TNl1rSsUIWEEE=",
|
"checksumSHA1": "Zgp5RqU+20L2p9TNl1rSsUIWEEE=",
|
||||||
|
|||||||
Reference in New Issue
Block a user