Skip to content

Commit

Permalink
Show correct commits in PR diff (#20)
Browse files Browse the repository at this point in the history
* Use parent commit as a base for showing PR diff

* update readme
  • Loading branch information
rikukissa committed Dec 30, 2017
1 parent 186e989 commit 0ea69d1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
Binary file added .github/diff-all-visible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/diff-pr-visible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/only-relevant.png
Binary file not shown.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
</p>


|<img alt="Pull request order visible in pull requests" src="./.github/list-view.png" height="250px" /> | <img alt="Select parent pull request" src="./.github/parent-selector.png" height="250px" /> |
|<img alt="Pull request order visible in pull requests" src="./.github/list-view.png" height="266px" /> | <img alt="Select parent pull request" src="./.github/parent-selector.png" height="266px" /> |
|--|--|

<p align="center">
<strong>View only changes made after the previous pull request</strong>
<strong>View only changes made in this pull request</strong>
</p>

|<img alt="Only relevant changes visible" src="./.github/only-relevant.png" height="200px" />|
|<img alt="Only relevant changes visible" src="./.github/diff-all-visible.png" />|
|--|
|<img alt="Only relevant changes visible" src="./.github/diff-pr-visible.png" />|

<p align="center">
<strong>Automatic warnings on sequential pull requests</strong>
Expand Down
1 change: 1 addition & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface IGithubFork {
}
export interface IGithubCommit {
sha: string;
parents: Array<{ sha: string }>;
}

async function makeRequest(
Expand Down
6 changes: 4 additions & 2 deletions src/features/diff-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function getDiffViewUrl(commits: IGithubCommit[]): string | null {
} else if (commits.length > 1) {
return (
window.location.href +
`/${commits[0].sha}..${commits[commits.length - 1].sha}`
// TODO this is a too big of an assumption
// https://softwareengineering.stackexchange.com/questions/314215/can-a-git-commit-have-more-than-2-parents
`/${commits[0].parents[0].sha}..${commits[commits.length - 1].sha}`
);
} else {
return null;
Expand Down Expand Up @@ -93,7 +95,7 @@ export default async function initialize(context: IStackerContext) {
>
Viewing all changes.{" "}
<a className="stale-files-tab-link" href={diffViewUrl}>
🔎 View only this PR
🔎 &nbsp;View only this PR
</a>
</div>,
$stats
Expand Down

0 comments on commit 0ea69d1

Please sign in to comment.