Skip to content

Commit

Permalink
feat: add order input #123.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 25, 2024
1 parent a495456 commit bc36781
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ jobs:
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
show-emoji: false
remove-type: true

- name: Order Changelog (ASC)
uses: ./
with:
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
show-emoji: false
remove-type: true

- name: Order Changelog (DESC)
uses: ./
with:
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
show-emoji: false
remove-type: true

- name: Generate Changelog (outputs.changelog)
run: echo "${{ steps.changelogEmoji.outputs.changelog }}"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Only use the following Git Commit Messages. A simple and small footprint is crit
- `base-ref` The name of the second branch. Defaults to the `tag_name` of the latest GitHub release. *This must be a GitHub release. Git tags or branches will not work.*
- `original-markdown` Default `true`, Output clean markdown content.
- `gh-pages` Default `gh-pages`, Specify the branch name to get the hash from
- `order` Default `asc`, Should the log results be displayed in descending (desc) or ascending (asc) order
- `path` Only commits containing this file path will be returned.
- `template` Define the log display template ([#111](https://github.com/jaywcjlove/changelog-generator/issues/111#issuecomment-1594085749)).
- `show-emoji` Show emoji icons. Default `true`.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: 'Specify the branch name to get the hash from'
default: 'gh-pages'
required: false
order:
description: 'Should the log results be displayed in descending (desc) or ascending (asc) order'
default: 'asc'
required: false
base-ref:
description: 'The name of the base reference'
default: ''
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const getOptions = () => {
baseRef: getInput('base-ref'),
myToken,
myPath: getInput('path'),
order: getInput('asc') as 'asc' | 'desc',
template: getInput('template'),
/** @example `type🆎,chore💄,fix🐞` Use commas to separate */
customEmoji: getInput('custom-emoji') || '',
Expand Down Expand Up @@ -167,7 +168,8 @@ async function run() {

let commitLog = [];
info(`ResultData Lenght:${resultData.length}`)
for (const data of resultData) {
const resData = options.order == 'asc' ? resultData : resultData.reverse();
for (const data of resData) {
const message = data.commit.message.split('\n\n')[0];
const author = data.author || data.committer || { login: '-' };
startGroup(`Commit: \x1b[34m${message}\x1b[0m \x1b[34m${(data.commit.author || {}).name}(${author.login})\x1b[0m ${data.sha}`);
Expand Down

0 comments on commit bc36781

Please sign in to comment.