@@ -94,65 +94,14 @@ struct IssueRef { int id; bool fixed; Json[] commits; }
94
94
// get all issues mentioned in a commit
95
95
IssueRef[] getIssueRefs (RE )(Json[] commits, RE re = issueRE)
96
96
{
97
- return commits
98
- // Collect all issue references (range of ranges per commit)
99
- .map! (c => c[" commit" ][" message" ]
100
- .get ! string
101
- .matchIssueRefs(re)
102
- .map! ((r) { r.commits = [c]; return r; })
103
- )
104
- // Join to flat list
105
- .join
106
- // Sort and group by issue ID
107
- .sort! ((a, b) => a.id < b.id, SwapStrategy.stable)
108
- .groupBy
109
- // Reduce each per-ID group to a single IssueRef
110
- .map! (g => g
111
- .reduce! ((a, b) =>
112
- IssueRef(a.id, a.fixed || b.fixed, a.commits ~ b.commits)
113
- )
114
- )
115
- .array;
116
- }
117
-
118
- unittest
119
- {
120
- Json fix (int id) { return [" commit" :[" message" :" Fix Bugzilla %d" .format(id).Json].Json].Json; }
121
- Json mention (int id) { return [" commit" :[" message" :" Bugzilla %d" .format(id).Json].Json].Json; }
122
-
123
- assert (getIssueRefs([fix(1 )]) == [IssueRef(1 , true , [fix(1 )])]);
124
- assert (getIssueRefs([mention(1 )]) == [IssueRef(1 , false , [mention(1 )])]);
125
- assert (getIssueRefs([fix(1 ), mention(1 )]) == [IssueRef(1 , true , [fix(1 ), mention(1 )])]);
126
- assert (getIssueRefs([mention(1 ), fix(1 )]) == [IssueRef(1 , true , [mention(1 ), fix(1 )])]);
127
- assert (getIssueRefs([mention(1 ), fix(2 ), fix(1 )]) == [IssueRef(1 , true , [mention(1 ), fix(1 )]), IssueRef(2 , true , [fix(2 )])]);
97
+ return null ;
128
98
}
129
99
130
100
UserMessage[] checkLegacyIssueRefs (Json[] commits)
131
101
{
132
- auto oldHits = commits.getIssueRefs(oldIssueRE).map! (r => r.id);
133
- auto newHits = commits.getIssueRefs(issueRE).map! (r => r.id);
134
- auto onlyOld = oldHits.filter! (id => ! newHits.canFind(id));
135
- if (! onlyOld.empty)
136
- return [UserMessage(UserMessage.Type.Warning,
137
- " In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. " ~
138
- " Please add the word \" Bugzilla\" to issue references. For example, `Fix Bugzilla Issue 12345` or `Fix Bugzilla 12345`." ~
139
- " (Reminder: the edit needs to be done in the Git *commit message*, not the GitHub *pull request*.)"
140
- )];
141
102
return null ;
142
103
}
143
104
144
- unittest
145
- {
146
- Json fixOld (int id) { return [" commit" :[" message" :" Fix Issue %d" .format(id).Json].Json].Json; }
147
- Json fixNew (int id) { return [" commit" :[" message" :" Fix Bugzilla %d" .format(id).Json].Json].Json; }
148
-
149
- assert ( checkLegacyIssueRefs([]).empty);
150
- assert ( checkLegacyIssueRefs([fixNew(1 )]).empty);
151
- assert ( checkLegacyIssueRefs([fixOld(1 ), fixNew(1 )]).empty);
152
- assert (! checkLegacyIssueRefs([fixOld(1 )]).empty);
153
- assert (! checkLegacyIssueRefs([fixOld(1 ), fixNew(2 )]).empty);
154
- }
155
-
156
105
struct Issue
157
106
{
158
107
int id;
0 commit comments