diff options
author | zeripath <art27@cantab.net> | 2019-07-01 02:18:13 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-07-01 09:18:13 +0800 |
commit | 3563650bdb273045c55400ee9520a0f78fc90e76 (patch) | |
tree | 29fa8994dd254361d42c7055db17ddef5143bb16 /cmd | |
parent | e5a4d784e8dda105832a28ccee0d593bf9dd6348 (diff) | |
download | gitea-3563650bdb273045c55400ee9520a0f78fc90e76.tar.gz gitea-3563650bdb273045c55400ee9520a0f78fc90e76.zip |
#6946 Run hooks on merge/edit and cope with protected branches (#6961)
* Fix #6946 by checking PullRequest ID on pushing
* Ensure we have the owner name, the pr attributes and the the issue
* Fix TestSearchRepo by waiting till indexing is done
* Update integrations/repo_search_test.go
* changes as per @mrsdizzie
* missing comma
* Spelling mistake
* Fix full pushing environment
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/hook.go | 2 | ||||
-rw-r--r-- | cmd/serv.go | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/cmd/hook.go b/cmd/hook.go index b3e900afee..ca876f02a3 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -65,6 +65,7 @@ func runHookPreReceive(c *cli.Context) error { username := os.Getenv(models.EnvRepoUsername) reponame := os.Getenv(models.EnvRepoName) userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64) + prID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchPRID), 10, 64) buf := bytes.NewBuffer(nil) scanner := bufio.NewScanner(os.Stdin) @@ -95,6 +96,7 @@ func runHookPreReceive(c *cli.Context) error { UserID: userID, GitAlternativeObjectDirectories: os.Getenv(private.GitAlternativeObjectDirectories), GitObjectDirectory: os.Getenv(private.GitObjectDirectory), + ProtectedBranchID: prID, }) switch statusCode { case http.StatusInternalServerError: diff --git a/cmd/serv.go b/cmd/serv.go index 2ea89757db..32dd8cbd3e 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -191,6 +191,7 @@ func runServ(c *cli.Context) error { os.Setenv(models.EnvPusherName, results.UserName) os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10)) os.Setenv(models.ProtectedBranchRepoID, strconv.FormatInt(results.RepoID, 10)) + os.Setenv(models.ProtectedBranchPRID, fmt.Sprintf("%d", 0)) //LFS token authentication if verb == lfsAuthenticateVerb { @@ -239,8 +240,6 @@ func runServ(c *cli.Context) error { gitcmd = exec.Command(verb, repoPath) } - os.Setenv(models.ProtectedBranchRepoID, fmt.Sprintf("%d", results.RepoID)) - gitcmd.Dir = setting.RepoRootPath gitcmd.Stdout = os.Stdout gitcmd.Stdin = os.Stdin |