Skip to content

Commit

Permalink
Link PRs in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Jun 30, 2017
1 parent 8e1dd2b commit cd81c42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "insomnia",
"version": "5.4.0",
"version": "5.5.2",
"productName": "Insomnia",
"longName": "Insomnia REST Client",
"description": "Debug APIs like a human, not a robot",
Expand Down
24 changes: 21 additions & 3 deletions app/ui/components/modals/changelog-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,30 @@ class ChangelogModal extends PureComponent {
];
}

const printThing = (text, key) => {
const match = text.match(/\(PR:(\d+)(:([^)]+))?\)/);
let link = null;
if (match) {
const prNumber = match[1];
const user = match[3] || '';
text = text.replace(match[0], '');
link = (
<Link href={`https://github.com/getinsomnia/insomnia/pull/${prNumber}`}>
#{prNumber}
{user ? ` by ${user}` : null}
</Link>
);
}

return <li key={key}>{text}{link && '('}{link}{link && ')'}</li>;
};

if (change.major && change.major.length) {
html = [
...html,
<h3 key={`major.${i}`}>Major</h3>,
<ul key={`major.${i}.list`}>
{change.major.map((text, i) => <li key={i}>{text}</li>)}
{change.major.map(printThing)}
</ul>
];
}
Expand All @@ -112,7 +130,7 @@ class ChangelogModal extends PureComponent {
...html,
<h3 key={`fixes.${i}`}>Bug Fixes</h3>,
<ul key={`fixes.${i}.list`}>
{change.fixes.map((text, j) => <li key={j}>{text}</li>)}
{change.fixes.map(printThing)}
</ul>
];
}
Expand All @@ -122,7 +140,7 @@ class ChangelogModal extends PureComponent {
...html,
<h3 key={`minor.${i}`}>Minor</h3>,
<ul key={`minor.${i}.list`}>
{change.minor.map((text, i) => <li key={i}>{text}</li>)}
{change.minor.map(printThing)}
</ul>
];
}
Expand Down

0 comments on commit cd81c42

Please sign in to comment.