4
4
"bytes"
5
5
"fmt"
6
6
"os"
7
+ "strconv"
7
8
"strings"
8
9
"text/template"
9
10
58
59
🎯 Milestone Desc : {{.milestoneDesc}}
59
60
🤡 Feature Branch : {{.featureBranch}}
60
61
👽 Milestone URL : {{.milestoneWebURL}}
61
- 🎠 Merge Requests :
62
62
`
63
- _featureDetailTblHeader = []string {"🎠MR#Flow" , "✈️MR#WebURL" , "🎯Issue#Title" , "✈️Issue#URL" }
63
+ _featureDetailTblHeader = []string {"MR#Src" , "MR#Target" , "MR#WebURL" , "Issue#IID" , "Issue#Desc" }
64
+ _featureDetailIssueTblHeader = []string {"Issue#IID" , "Issue#Title" , "Issue#Desc" , "Issue#WebURL" }
64
65
)
65
66
66
67
func init () {
@@ -94,7 +95,10 @@ func (d dashImpl) fillContextWithProject() error {
94
95
return fmt .Errorf ("could not match project(%s) from remote: %v" , projectName , err )
95
96
}
96
97
97
- // FeatureDetail get feature detail of current project
98
+ // FeatureDetail get feature detail of current project:
99
+ // * basic information to current milestone.
100
+ // * all merge request and its related issue created in current milestone.
101
+ // * all issues created in current milestone with web url.
98
102
func (d dashImpl ) FeatureDetail (featureBranchName string ) ([]byte , error ) {
99
103
if featureBranchName == "" {
100
104
featureBranchName , _ = d .gitOperator .CurrentBranch ()
@@ -142,11 +146,18 @@ func (d dashImpl) FeatureDetail(featureBranchName string) ([]byte, error) {
142
146
143
147
// rework issue
144
148
issueCache := make (map [int ]* repository.IssueDO )
145
- for _ , v := range issues {
149
+ issueTblData := make ([][]string , len (issues ))
150
+ for idx , v := range issues {
146
151
issueCache [v .IssueIID ] = v
152
+ issueTblData [idx ] = []string {
153
+ strconv .Itoa (v .IssueIID ),
154
+ v .Title ,
155
+ v .Desc ,
156
+ v .WebURL ,
157
+ }
147
158
}
148
159
149
- tblData := make ([][]string , len (mrs ))
160
+ mrTblData := make ([][]string , len (mrs ))
150
161
for idx , mr := range mrs {
151
162
issue , ok := issueCache [mr .IssueIID ]
152
163
if ! ok {
@@ -158,18 +169,18 @@ func (d dashImpl) FeatureDetail(featureBranchName string) ([]byte, error) {
158
169
issue = new (repository.IssueDO )
159
170
}
160
171
161
- tblData [idx ] = []string {
162
- //strconv.Itoa( mr.MergeRequestID), // MR-ID
163
- fmt . Sprintf ( "%s🇨🇳 %s" , mr .SourceBranch , mr . TargetBranch ), // mr action
164
- mr .WebURL , // MR-URL
165
- issue .Title , // issue.Name
166
- issue .WebURL , // issue.IssueURL
172
+ mrTblData [idx ] = []string {
173
+ mr .SourceBranch , //
174
+ mr .TargetBranch , //
175
+ mr .WebURL , // MR-URL
176
+ strconv . Itoa ( issue .IssueIID ), // issue.issueIID
177
+ issue .Desc , // issue.Title
167
178
}
168
179
}
169
180
170
181
log .
171
- WithFields (log.Fields {"tblData " : tblData }).
172
- Debug ("tblData is conducted" )
182
+ WithFields (log.Fields {"mrTblData " : mrTblData }).
183
+ Debug ("mrTblData is conducted" )
173
184
174
185
data := map [string ]interface {}{
175
186
"projectTitle" : d .ctx .Project .Name ,
@@ -186,11 +197,49 @@ func (d dashImpl) FeatureDetail(featureBranchName string) ([]byte, error) {
186
197
return nil , errors .Wrap (err , "detailTpl.Execute" )
187
198
}
188
199
200
+ buf .WriteString ("All Merge Requests:\n " )
201
+
202
+ // output all merge request into table
189
203
w := tablewriter .NewWriter (buf )
190
204
w .SetHeader (_featureDetailTblHeader )
191
- w .AppendBulk (tblData )
205
+ w .SetHeaderAlignment (tablewriter .ALIGN_LEFT )
206
+ w .SetAlignment (tablewriter .ALIGN_LEFT )
207
+ for _ , row := range mrTblData {
208
+ // if master merge request
209
+ if row [1 ] == types .MasterBranch .String () {
210
+ w .Rich (row , []tablewriter.Colors {
211
+ {tablewriter .Bold , tablewriter .FgHiRedColor },
212
+ {tablewriter .Bold , tablewriter .FgHiRedColor },
213
+ {},
214
+ {tablewriter .Bold , tablewriter .FgBlackColor },
215
+ })
216
+ continue
217
+ }
218
+
219
+ if row [1 ] == types .TestBranch .String () {
220
+ w .Rich (row , []tablewriter.Colors {
221
+ {tablewriter .Bold , tablewriter .FgHiGreenColor },
222
+ {tablewriter .Bold , tablewriter .FgHiGreenColor },
223
+ {},
224
+ {tablewriter .Bold , tablewriter .FgBlackColor },
225
+ })
226
+ continue
227
+ }
228
+
229
+ w .Append (row )
230
+ }
192
231
w .Render ()
193
232
233
+ buf .WriteString ("All Issues:\n " )
234
+
235
+ // output all issues into detail
236
+ w2 := tablewriter .NewWriter (buf )
237
+ w2 .SetHeader (_featureDetailIssueTblHeader )
238
+ w2 .SetHeaderAlignment (tablewriter .ALIGN_LEFT )
239
+ w2 .SetAlignment (tablewriter .ALIGN_LEFT )
240
+ w2 .AppendBulk (issueTblData )
241
+ w2 .Render ()
242
+
194
243
return buf .Bytes (), nil
195
244
}
196
245
0 commit comments