Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2460fac

Browse files
committed
Fix the tag sorting issue
1 parent59bfea3 commit2460fac

File tree

1 file changed

+52
-5
lines changed

1 file changed

+52
-5
lines changed

‎lib/src/Gren.js‎

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ class Gren {
290290
*
291291
*@since 0.1.0
292292
*@private
293+
*@deprecated
293294
*
294295
*@param {Array} releases
295296
*@param {number} page
@@ -327,6 +328,49 @@ class Gren {
327328
returnfilteredTags;
328329
}
329330

331+
/**
332+
* Get all the tags of the repo
333+
*
334+
*@since 0.1.0
335+
*@private
336+
*@deprecated
337+
*
338+
*@param {Array} releases
339+
*@param {number} page
340+
*
341+
*@return {Promise}
342+
*/
343+
async_getAllTags(releases,page=1,limit=this.options.limit){
344+
const{headers:{ link},data:tags}=awaitthis._listTags({
345+
per_page:limit,
346+
page
347+
});
348+
349+
if(!tags.length){
350+
throwchalk.red('\nLooks like you have no tags! Tag a commit first and then run gren again');
351+
}
352+
353+
constfilteredTags=tags
354+
.filter((tag)=>tag&&this.options.ignoreTagsWith.every(ignoreTag=>!tag.name.match(ignoreTag)))
355+
.map(tag=>{
356+
consttagRelease=releases ?releases.filter(release=>release.tag_name===tag.name)[0] :false;
357+
constreleaseId=tagRelease ?tagRelease.id :null;
358+
359+
return{
360+
tag:tag,
361+
releaseId:releaseId
362+
};
363+
});
364+
365+
consttotalPages=this._getLastPage(link);
366+
367+
if(totalPages&&page<totalPages){
368+
returnthis._getAllTags(releases,page+1).then(moreTags=>moreTags.concat(filteredTags));
369+
}
370+
371+
returnfilteredTags;
372+
}
373+
330374
/**
331375
* Get the dates of the last two tags
332376
*
@@ -1079,19 +1123,22 @@ class Gren {
10791123
constreleases=awaitthis._getListReleases();
10801124
this.tasks['Getting releases'].text='Getting tags';
10811125

1082-
consttags=awaitthis._getLastTags(releases.length ?releases :false);
1126+
consttags=awaitthis._getAllTags(releases.length ?releases :false);
1127+
10831128
this._validateRequiredTagsExists(tags,this.options.tags);
1084-
constreleaseDates=awaitPromise.all(this._getTagDates(tags));
10851129

1086-
loaded(`Tags found:${tags.map(({tag:{ name}})=>name).join(', ')}`);
1130+
constreleaseDates=this._sortReleasesByDate(awaitPromise.all(this._getTagDates(tags)));
1131+
constselectedTags=(this._getSelectedTags(releaseDates)||[releaseDates[0],releaseDates[1]]);
1132+
1133+
loaded(`Tags found:${selectedTags.map(({ name})=>name).join(', ')}`);
10871134

10881135
returndataSource[this.options.dataSource](
1089-
this._createReleaseRanges(releaseDates)
1136+
this._createReleaseRanges(selectedTags)
10901137
);
10911138
}
10921139

10931140
/**
1094-
* Check that the require tagsare exists in tags
1141+
* Check that the require tagsexist in tags
10951142
*
10961143
*@param {Array} tags
10971144
*@param {Array} requireTags

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp