| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package buildbucket | 5 package buildbucket |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "strings" | 10 "strings" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // getChangeList tries to extract CL information from a buildbucket build. | 106 // getChangeList tries to extract CL information from a buildbucket build. |
| 107 func getChangeList( | 107 func getChangeList( |
| 108 build *buildbucket.ApiBuildMessage, params *buildParameters, | 108 build *buildbucket.ApiBuildMessage, params *buildParameters, |
| 109 resultDetails *resultDetails) (result *resp.Commit) { | 109 resultDetails *resultDetails) (result *resp.Commit) { |
| 110 | 110 |
| 111 prop := ¶ms.Properties | 111 prop := ¶ms.Properties |
| 112 switch prop.PatchStorage { | 112 switch prop.PatchStorage { |
| 113 case "rietveld": | 113 case "rietveld": |
| 114 if prop.RietveldURL != "" && prop.Issue != 0 { | 114 if prop.RietveldURL != "" && prop.Issue != 0 { |
| 115 result = &resp.Commit{ | 115 result = &resp.Commit{ |
| 116 » » » » Revision: resultDetails.Properties.GotRev
ision, | 116 » » » » RequestRevision: &resp.Link{Label: prop.Revision
}, |
| 117 » » » » RequestRevision: prop.Revision, | |
| 118 Changelist: &resp.Link{ | 117 Changelist: &resp.Link{ |
| 119 Label: fmt.Sprintf("Rietveld CL %d", pro
p.Issue), | 118 Label: fmt.Sprintf("Rietveld CL %d", pro
p.Issue), |
| 120 URL: fmt.Sprintf("%s/%d/#ps%d", prop.R
ietveldURL, prop.Issue, prop.PatchSet), | 119 URL: fmt.Sprintf("%s/%d/#ps%d", prop.R
ietveldURL, prop.Issue, prop.PatchSet), |
| 121 }, | 120 }, |
| 122 } | 121 } |
| 122 if resultDetails.Properties.GotRevision != "" { |
| 123 // TODO(hinoka): Figure out the full URL for the
se revisions, add it |
| 124 // to the URL field. |
| 125 result.Revision = &resp.Link{Label: resultDetail
s.Properties.GotRevision} |
| 126 } |
| 123 } | 127 } |
| 124 | 128 |
| 125 case "gerrit": | 129 case "gerrit": |
| 126 if prop.GerritPatchURL != "" && prop.GerritPatchIssue != 0 { | 130 if prop.GerritPatchURL != "" && prop.GerritPatchIssue != 0 { |
| 127 path := fmt.Sprintf("%d", prop.GerritPatchIssue) | 131 path := fmt.Sprintf("%d", prop.GerritPatchIssue) |
| 128 if prop.GerritPatchSet != 0 { | 132 if prop.GerritPatchSet != 0 { |
| 129 path = fmt.Sprintf("%d/%d", prop.GerritPatchIssu
e, prop.GerritPatchSet) | 133 path = fmt.Sprintf("%d/%d", prop.GerritPatchIssu
e, prop.GerritPatchSet) |
| 130 } | 134 } |
| 131 result = &resp.Commit{ | 135 result = &resp.Commit{ |
| 132 Changelist: &resp.Link{ | 136 Changelist: &resp.Link{ |
| 133 Label: fmt.Sprintf("Gerrit CL %d", prop.
GerritPatchIssue), | 137 Label: fmt.Sprintf("Gerrit CL %d", prop.
GerritPatchIssue), |
| 134 URL: fmt.Sprintf( | 138 URL: fmt.Sprintf( |
| 135 "%s/c/%s", prop.GerritPatchURL,
path), | 139 "%s/c/%s", prop.GerritPatchURL,
path), |
| 136 }, | 140 }, |
| 137 } | 141 } |
| 138 } | 142 } |
| 139 } | 143 } |
| 140 | 144 |
| 141 if result != nil && len(params.Changes) != 0 { | 145 if result != nil && len(params.Changes) != 0 { |
| 142 // tryjobs have one change and it is the CL author | 146 // tryjobs have one change and it is the CL author |
| 143 result.AuthorEmail = params.Changes[0].Author.Email | 147 result.AuthorEmail = params.Changes[0].Author.Email |
| 144 } | 148 } |
| 145 | 149 |
| 146 return | 150 return |
| 147 } | 151 } |
| OLD | NEW |