Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to the new pull request button #6248

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b5f4911
Documentation: Clarity for HTTPS setups (#5626)
0x5c Jan 3, 2019
14e218c
Backport latest translation changes
lafriks Jan 4, 2019
3ee3a4b
SECURITY: protect DeleteFilePost et al with cleanUploadFileName (#563…
zeripath Jan 4, 2019
109fc79
Add changelog for 1.6.3 and 1.7.0-rc2 (#5638)
jonasfranz Jan 4, 2019
2904d8d
Fix sqlite deadlock when assigning to a PR (#5640) (#5642)
zeripath Jan 5, 2019
c9b57a5
Don't close issues via commits on non-default branch. (#5622) (#5643)
HarshitOnGitHub Jan 5, 2019
652e09f
fix commit page showing status for current default branch (#5650) (#5…
apricote Jan 6, 2019
41a2bfe
Only count users own actions for heatmap contributions (#5647) (#5655)
apricote Jan 6, 2019
551dc58
When redirecting clean the path to avoid redirecting to //www.othersi…
zeripath Jan 9, 2019
483aa06
fix public will not be reused as public key after deleting as deploy …
lunny Jan 10, 2019
176a604
Update xorm to fix issue #5659 and #5651 (#5680) (#5692)
gzsombor Jan 10, 2019
e9c4609
Do not display the raw OpenID error in the UI (#5705) (#5712)
zeripath Jan 13, 2019
8d40032
fix: use correct value for "MSpan Structures Obtained" #4742 (#5706) …
apricote Jan 13, 2019
8006b1b
backport 1.6.4 changelog to 1.7 branch (#5741)
techknowlogick Jan 16, 2019
8da5237
1.7.0-rc3 changelog (#5756)
techknowlogick Jan 18, 2019
4577cdd
Disallow empty titles (#5785) (#5794)
adelowo Jan 21, 2019
3fa49f3
1.7.0 changelog (#5802)
techknowlogick Jan 22, 2019
f635041
Fix TLS errors when using acme/autocert for local connections (#5820)…
joohoi Jan 24, 2019
2c26521
Request for public keys only if LDAP attribute is set (#5816) (#5819)
lafriks Jan 24, 2019
f28e174
Backport #5830 : Include Go toolchain to --version (#5832)
sapk Jan 24, 2019
8a9f5b3
Added docs for the tree api (#5835)
kolaente Jan 24, 2019
28d9305
Fix delete correct temp directory (#5840)
yasuokav Jan 25, 2019
d3a334d
Fix an error while adding a dependency via UI. (Backport #5862) (#5876)
HarshitOnGitHub Jan 28, 2019
2979953
API: Fix null pointer in attempt to Sudo if not logged in (#5872) (#5…
zeripath Jan 28, 2019
4fe1a30
When creating new repository fsck option should be enabled (#5817) (#…
lafriks Jan 29, 2019
0190d3c
Prevent nil dereference in mailIssueCommentToParticipants (#5891, #58…
zeripath Jan 29, 2019
3f802a2
Fix go-get URL generation (#5905) (#5907)
lafriks Jan 30, 2019
e5af93a
Only allow local login if password is non-empty (#5906) (#5908)
zeripath Jan 30, 2019
9d4aa78
Fix bug when read public repo lfs file (#5913)
lunny Jan 31, 2019
438848a
respect value of REQUIRE_SIGNIN_VIEW (#5901) (#5915)
adelowo Jan 31, 2019
5c30817
fix compare button on upstream repo leading to 404 (#5877) (#5914)
adelowo Jan 31, 2019
c3b67ff
Disable redirect for i18n (#5910) (#5916)
techknowlogick Jan 31, 2019
dfad569
1.7.1 changelog (#5918)
techknowlogick Jan 31, 2019
022634a
Remove all CommitStatus when a repo is deleted (#5941)
jolheiser Feb 3, 2019
7312752
Fix notifications on pushing with deploy keys by setting hook environ…
zeripath Feb 3, 2019
849c85a
Fix #5866: Silence console logger in gitea serv (#5887) (#5943)
zeripath Feb 3, 2019
477b4de
handle milestone events for issues and PR (#5947) (#5955)
adelowo Feb 4, 2019
1a8ab63
show user who created the repository instead of the organization in a…
adelowo Feb 4, 2019
6416f06
Fix ssh deploy and user key constraints (#1357) (#5939) (#5966)
zeripath Feb 4, 2019
d269179
fix bug when deleting a linked account will removed all (#5989) (#5990)
lunny Feb 7, 2019
b0b574f
Fix empty ssh key importing in ldap (#5984) (#6009)
zeripath Feb 9, 2019
7f7c451
Fix metrics auth token detection (#6006) (#6017)
barkap Feb 9, 2019
c8f061e
Create repository on organisation by default on its dashboard (#6026)…
zeripath Feb 13, 2019
253efbc
Make sure labels are actually returned (#6053) (#6059)
adelowo Feb 13, 2019
3ac4a7f
Switch to more recent build of xgo (#6070) (#6072)
techknowlogick Feb 14, 2019
57ab65d
1.7.2 changelog (#6079)
techknowlogick Feb 15, 2019
1d8e56e
In basic auth check for tokens before call UserSignIn (#5725) (#6083)
lafriks Feb 15, 2019
3b612ce
Changelog for release v1.7.2 (#6084)
lafriks Feb 15, 2019
31c376b
Fixing new pull requests button
Mar 5, 2019
fc2902f
Fixing new pull request button
Mar 5, 2019
5df616c
Pull request 404 was a front end only issue.
Mar 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .drone.yml
Expand Up @@ -211,7 +211,7 @@ pipeline:
branch: [ master ]

static:
image: karalabe/xgo-latest:latest
image: techknowlogick/xgo:latest
pull: true
environment:
TAGS: bindata sqlite sqlite_unlock_notify
Expand Down
62 changes: 61 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,48 @@ This changelog goes through all the changes that have been made in each release
without substantial changes to our git log; to see the highlights of what has
been added to each release, please refer to the [blog](https://blog.gitea.io).

## [1.7.0-rc1](https://github.com/go-gitea/gitea/releases/tag/v1.7.0) - 2019-01-02
## [1.7.2](https://github.com/go-gitea/gitea/releases/tag/v1.7.2) - 2019-02-14
* BUGFIXES
* Remove all CommitStatus when a repo is deleted (#5940) (#5941)
* Fix notifications on pushing with deploy keys by setting hook environment variables (#5935) (#5944)
* Silence console logger in gitea serv (#5887) (#5943)
* Handle milestone webhook events for issues and PR (#5947) (#5955)
* Show user who created the repository instead of the organization in action feed (#5948) (#5956)
* Fix ssh deploy and user key constraints (#1357) (#5939) (#5966)
* Fix bug when deleting a linked account will removed all (#5989) (#5990)
* Fix empty ssh key importing in ldap (#5984) (#6009)
* Fix metrics auth token detection (#6006) (#6017)
* Create repository on organisation by default on its dashboard (#6026) (#6048)
* Make sure labels are actually returned in API (#6053) (#6059)
* Switch to more recent build of xgo (#6070) (#6072)
* In basic auth check for tokens before call UserSignIn (#5725) (#6083)

## [1.7.1](https://github.com/go-gitea/gitea/releases/tag/v1.7.1) - 2019-01-31
* SECURITY
* Disable redirect for i18n (#5910) (#5916)
* Only allow local login if password is non-empty (#5906) (#5908)
* Fix go-get URL generation (#5905) (#5907)
* BUGFIXES
* Fix TLS errors when using acme/autocert for local connections (#5820) (#5826)
* Request for public keys only if LDAP attribute is set (#5816) (#5819)
* Fix delete correct temp directory (#5840) (#5839)
* Fix an error while adding a dependency via UI (#5862) (#5876)
* Fix null pointer in attempt to Sudo if not logged in (#5872) (#5884)
* When creating new repository fsck option should be enabled (#5817) (#5885)
* Prevent nil dereference in mailIssueCommentToParticipants (#5891) (#5895) (#5894)
* Fix bug when read public repo lfs file (#5913) (#5912)
* Respect value of REQUIRE_SIGNIN_VIEW (#5901) (#5915)
* Fix compare button on upstream repo leading to 404 (#5877) (#5914)
* DOCS
* Added docs for the tree api (#5835)
* MISC
* Include Go toolchain to --version (#5832) (#5830)

## [1.7.0](https://github.com/go-gitea/gitea/releases/tag/v1.7.0) - 2019-01-22
* SECURITY
* Do not display the raw OpenID error in the UI (#5705) (#5712)
* When redirecting clean the path to avoid redirecting to external site (#5669) (#5679)
* Prevent DeleteFilePost doing arbitrary deletion (#5631)
* BREAKING
* Restrict permission check on repositories and fix some problems (#5314)
* Show only opened milestones on issues page milestone filter (#5051)
Expand All @@ -23,6 +64,13 @@ been added to each release, please refer to the [blog](https://blog.gitea.io).
* Give user a link to create PR after push (#4716)
* Add rebase with merge commit merge style (#3844) (#4052)
* BUGFIXES
* Disallow empty titles (#5785) (#5794)
* Fix sqlite deadlock when assigning to a PR (#5640) (#5642)
* Don't close issues via commits on non-default branch. (#5622) (#5643)
* Fix commit page showing status for current default branch (#5650) (#5653)
* Only count users own actions for heatmap contributions (#5647) (#5655)
* Update xorm to fix issue postgresql dumping issues (#5680) (#5692)
* Use correct value for "MSpan Structures Obtained" (#5706) (#5716)
* Fix bug on modifying sshd username (#5624)
* Delete tags in mirror which are removed for original repo. (#5609)
* Fix wrong text getting saved on editing second comment on an issue. (#5608)
Expand Down Expand Up @@ -149,6 +197,18 @@ been added to each release, please refer to the [blog](https://blog.gitea.io).
* Git-Trees API (#5403)
* Only chown directories during docker setup if necessary. Fix #4425 (#5064)

## [1.6.4](https://github.com/go-gitea/gitea/releases/tag/v1.6.4) - 2019-01-15
* BUGFIX
* Fix SSH key now can be reused as public key after deleting as deploy key (#5671) (#5685)
* When redirecting clean the path to avoid redirecting to external site (#5669) (#5703)
* Fix to use correct value for "MSpan Structures Obtained" (#5706) (#5715)

## [1.6.3](https://github.com/go-gitea/gitea/releases/tag/v1.6.3) - 2019-01-04
* SECURITY
* Prevent DeleteFilePost doing arbitrary deletion (#5631)
* BUGFIX
* Fix wrong text getting saved on editing second comment on an issue (#5608)

## [1.6.2](https://github.com/go-gitea/gitea/releases/tag/v1.6.2) - 2018-12-21
* SECURITY
* Sanitize uploaded file names (#5571) (#5573)
Expand Down
11 changes: 6 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Expand Up @@ -38,7 +38,7 @@ ignored = ["google.golang.org/appengine*"]

[[override]]
name = "github.com/go-xorm/xorm"
revision = "401f4ee8ff8cbc40a4754cb12192fbe4f02f3979"
revision = "1cd2662be938bfee0e34af92fe448513e0560fb1"

[[override]]
name = "github.com/go-xorm/builder"
Expand Down
5 changes: 3 additions & 2 deletions cmd/cmd.go
Expand Up @@ -9,10 +9,11 @@ package cmd
import (
"errors"
"fmt"
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"

"github.com/urfave/cli"
)

Expand All @@ -24,7 +25,7 @@ func argsSet(c *cli.Context, args ...string) error {
return errors.New(a + " is not set")
}

if len(strings.TrimSpace(c.String(a))) == 0 {
if util.IsEmptyString(a) {
return errors.New(a + " is required")
}
}
Expand Down
22 changes: 15 additions & 7 deletions cmd/serv.go
Expand Up @@ -70,6 +70,7 @@ func checkLFSVersion() {
}

func setup(logPath string) {
log.DelLogger("console")
setting.NewContext()
checkLFSVersion()
log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
Expand Down Expand Up @@ -233,23 +234,30 @@ func runServ(c *cli.Context) error {

// Check deploy key or user key.
if key.Type == models.KeyTypeDeploy {
if key.Mode < requestedMode {
fail("Key permission denied", "Cannot push with deployment key: %d", key.ID)
}

// Check if this deploy key belongs to current repository.
has, err := private.HasDeployKey(key.ID, repo.ID)
// Now we have to get the deploy key for this repo
deployKey, err := private.GetDeployKey(key.ID, repo.ID)
if err != nil {
fail("Key access denied", "Failed to access internal api: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
}
if !has {

if deployKey == nil {
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
}

if deployKey.Mode < requestedMode {
fail("Key permission denied", "Cannot push with read-only deployment key: %d to repo_id: %d", key.ID, repo.ID)
}

// Update deploy key activity.
if err = private.UpdateDeployKeyUpdated(key.ID, repo.ID); err != nil {
fail("Internal error", "UpdateDeployKey: %v", err)
}

// FIXME: Deploy keys aren't really the owner of the repo pushing changes
// however we don't have good way of representing deploy keys in hook.go
// so for now use the owner
os.Setenv(models.EnvPusherName, username)
os.Setenv(models.EnvPusherID, fmt.Sprintf("%d", repo.OwnerID))
} else {
user, err = private.GetUserByKeyID(key.ID)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Expand Up @@ -122,9 +122,8 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `LFS_CONTENT_PATH`: **./data/lfs**: Where to store LFS files.
- `LFS_JWT_SECRET`: **\<empty\>**: LFS authentication secret, change this a unique string.
- `LFS_HTTP_AUTH_EXPIRY`: **20m**: LFS authentication validity period in time.Duration, pushes taking longer than this may fail.
- `REDIRECT_OTHER_PORT`: **false**: If true and `PROTOCOL` is https, redirects http requests
on another (https) port.
- `PORT_TO_REDIRECT`: **80**: Port used when `REDIRECT_OTHER_PORT` is true.
- `REDIRECT_OTHER_PORT`: **false**: If true and `PROTOCOL` is https, allows redirecting http requests on `PORT_TO_REDIRECT` to the https port Gitea listens on.
- `PORT_TO_REDIRECT`: **80**: Port for the http redirection service to listen on. Used when `REDIRECT_OTHER_PORT` is true.
- `ENABLE_LETSENCRYPT`: **false**: If enabled you must set `DOMAIN` to valid internet facing domain (ensure DNS is set and port 80 is accessible by letsencrypt validation server).
By using Lets Encrypt **you must consent** to their [terms of service](https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf).
- `LETSENCRYPT_ACCEPTTOS`: **false**: This is an explicit check that you accept the terms of service for Let's Encrypt.
Expand Down
14 changes: 14 additions & 0 deletions docs/content/doc/usage/https-support.md
Expand Up @@ -30,8 +30,22 @@ HTTP_PORT = 3000
CERT_FILE = cert.pem
KEY_FILE = key.pem
```

To learn more about the config values, please checkout the [Config Cheat Sheet](../config-cheat-sheet#server).

### Setting-up HTTP redirection

The Gitea server is only able to listen to one port; to redirect HTTP requests to the HTTPS port, you will need to enable the HTTP redirection service:

```ini
[server]
REDIRECT_OTHER_PORT = true
; Port the redirection service should listen on
PORT_TO_REDIRECT = 3080
```

If you are using Docker, make sure that this port is configured in your `docker-compose.yml` file.

## Using Let's Encrypt

[Let's Encrypt](https://letsencrypt.org/) is a Certificate Authority that allows you to automatically request and renew SSL/TLS certificates. In addition to starting Gitea on your configured port, to request HTTPS certificates Gitea will also need to listed on port 80, and will set up an autoredirect to HTTPS for you. Let's Encrypt will need to be able to access Gitea via the Internet to verify your ownership of the domain.
Expand Down
152 changes: 152 additions & 0 deletions integrations/api_helper_for_declarative_test.go
@@ -0,0 +1,152 @@
// Copyright 2019 The Gitea 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 (
"fmt"
"io/ioutil"
"net/http"
"testing"

api "code.gitea.io/sdk/gitea"
"github.com/stretchr/testify/assert"
)

type APITestContext struct {
Reponame string
Session *TestSession
Token string
Username string
ExpectedCode int
}

func NewAPITestContext(t *testing.T, username, reponame string) APITestContext {
session := loginUser(t, username)
token := getTokenForLoggedInUser(t, session)
return APITestContext{
Session: session,
Token: token,
Username: username,
Reponame: reponame,
}
}

func (ctx APITestContext) GitPath() string {
return fmt.Sprintf("%s/%s.git", ctx.Username, ctx.Reponame)
}

func doAPICreateRepository(ctx APITestContext, empty bool, callback ...func(*testing.T, api.Repository)) func(*testing.T) {
return func(t *testing.T) {
createRepoOption := &api.CreateRepoOption{
AutoInit: !empty,
Description: "Temporary repo",
Name: ctx.Reponame,
Private: true,
Gitignores: "",
License: "WTFPL",
Readme: "Default",
}
req := NewRequestWithJSON(t, "POST", "/api/v1/user/repos?token="+ctx.Token, createRepoOption)
if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
resp := ctx.Session.MakeRequest(t, req, http.StatusCreated)

var repository api.Repository
DecodeJSON(t, resp, &repository)
if len(callback) > 0 {
callback[0](t, repository)
}
}
}

func doAPIGetRepository(ctx APITestContext, callback ...func(*testing.T, api.Repository)) func(*testing.T) {
return func(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", ctx.Username, ctx.Reponame, ctx.Token)

req := NewRequest(t, "GET", urlStr)
if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
resp := ctx.Session.MakeRequest(t, req, http.StatusOK)

var repository api.Repository
DecodeJSON(t, resp, &repository)
if len(callback) > 0 {
callback[0](t, repository)
}
}
}

func doAPIDeleteRepository(ctx APITestContext) func(*testing.T) {
return func(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", ctx.Username, ctx.Reponame, ctx.Token)

req := NewRequest(t, "DELETE", urlStr)
if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
ctx.Session.MakeRequest(t, req, http.StatusNoContent)
}
}

func doAPICreateUserKey(ctx APITestContext, keyname, keyFile string, callback ...func(*testing.T, api.PublicKey)) func(*testing.T) {
return func(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/user/keys?token=%s", ctx.Token)

dataPubKey, err := ioutil.ReadFile(keyFile + ".pub")
assert.NoError(t, err)
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateKeyOption{
Title: keyname,
Key: string(dataPubKey),
})
if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
resp := ctx.Session.MakeRequest(t, req, http.StatusCreated)
var publicKey api.PublicKey
DecodeJSON(t, resp, &publicKey)
if len(callback) > 0 {
callback[0](t, publicKey)
}
}
}

func doAPIDeleteUserKey(ctx APITestContext, keyID int64) func(*testing.T) {
return func(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/user/keys/%d?token=%s", keyID, ctx.Token)

req := NewRequest(t, "DELETE", urlStr)
if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
ctx.Session.MakeRequest(t, req, http.StatusNoContent)
}
}

func doAPICreateDeployKey(ctx APITestContext, keyname, keyFile string, readOnly bool) func(*testing.T) {
return func(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/keys?token=%s", ctx.Username, ctx.Reponame, ctx.Token)

dataPubKey, err := ioutil.ReadFile(keyFile + ".pub")
assert.NoError(t, err)
req := NewRequestWithJSON(t, "POST", urlStr, api.CreateKeyOption{
Title: keyname,
Key: string(dataPubKey),
ReadOnly: readOnly,
})

if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
ctx.Session.MakeRequest(t, req, http.StatusCreated)
}
}