Skip to content

Commit

Permalink
fix(api): git info are not valid when running a fork (#4203)
Browse files Browse the repository at this point in the history
close #4201

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information
richardlt authored and yesnault committed Oct 9, 2019
1 parent bd8c3f8 commit e1016fc
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 24 deletions.
10 changes: 10 additions & 0 deletions .golangci.yml
Expand Up @@ -3,3 +3,13 @@
service:
prepare:
- apt-get update && apt-get install -y libsecret-1-dev
- go get github.com/labstack/echo
- go get github.com/fsamin/smtp

run:
skip-dirs:
- ui
- doc
- tests
skip-files:
- ".*_test.go$"
6 changes: 3 additions & 3 deletions engine/api/workflow/dao_run_test.go
Expand Up @@ -119,7 +119,7 @@ func TestPurgeWorkflowRun(t *testing.T) {
if err := enc.Encode([]sdk.VCSBranch{b}); err != nil {
return writeError(w, err)
}
// NEED GET BRANCH TO GET LASTEST COMMIT
// NEED GET BRANCH TO GET LATEST COMMIT
case "/vcs/github/repos/sguiheux/demo/branches/?branch=master":
b := sdk.VCSBranch{
Default: false,
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestPurgeWorkflowRunWithOneSuccessWorkflowRun(t *testing.T) {
if err := enc.Encode(repo); err != nil {
return writeError(w, err)
}
// NEED GET BRANCH TO GET LASTEST COMMIT
// NEED GET BRANCH TO GET LATEST COMMIT
case "/vcs/github/repos/sguiheux/demo/branches/?branch=master":
b := sdk.VCSBranch{
Default: false,
Expand Down Expand Up @@ -570,7 +570,7 @@ func TestPurgeWorkflowRunWithNoSuccessWorkflowRun(t *testing.T) {
if err := enc.Encode(repo); err != nil {
return writeError(w, err)
}
// NEED GET BRANCH TO GET LASTEST COMMIT
// NEED GET BRANCH TO GET LATEST COMMIT
case "/vcs/github/repos/sguiheux/demo/branches/?branch=master":
b := sdk.VCSBranch{
Default: false,
Expand Down
3 changes: 2 additions & 1 deletion engine/api/workflow/process_node.go
Expand Up @@ -204,7 +204,8 @@ func processNode(ctx context.Context, db gorp.SqlExecutor, store cache.Store, pr
found := false
for _, parent := range wr.WorkflowNodeRuns {
repo := sdk.ParameterFind(&parent[0].BuildParameters, tagGitRepository)
if repo != nil && repo.Value == currentRepo {
// if same repo OR not same repo, and same application, but different repo, it's a fork
if repo != nil && (repo.Value == currentRepo || parent[0].ApplicationID == n.Context.ApplicationID) {
found = true
// copy git info from ancestors
for _, param := range parent[0].BuildParameters {
Expand Down

0 comments on commit e1016fc

Please sign in to comment.