diff --git a/lib/views/file-patch-header-view.js b/lib/views/file-patch-header-view.js
index eba8278094..1425221120 100644
--- a/lib/views/file-patch-header-view.js
+++ b/lib/views/file-patch-header-view.js
@@ -13,6 +13,7 @@ import {ItemTypePropType} from '../prop-types';
export default class FilePatchHeaderView extends React.Component {
static propTypes = {
relPath: PropTypes.string.isRequired,
+ newPath: PropTypes.string,
stagingStatus: PropTypes.oneOf(['staged', 'unstaged']),
isPartiallyStaged: PropTypes.bool,
hasHunks: PropTypes.bool.isRequired,
@@ -51,16 +52,26 @@ export default class FilePatchHeaderView extends React.Component {
if (this.props.itemType === ChangedFileItem) {
const status = this.props.stagingStatus;
return (
- {status[0].toUpperCase()}{status.slice(1)} Changes for {this.renderPath()}
+ {status[0].toUpperCase()}{status.slice(1)} Changes for {this.renderDisplayPath()}
);
} else {
- return this.renderPath();
+ return this.renderDisplayPath();
}
}
- renderPath() {
- const dirname = path.dirname(this.props.relPath);
- const basename = path.basename(this.props.relPath);
+ renderDisplayPath() {
+ if (this.props.newPath && this.props.newPath !== this.props.relPath) {
+ const oldPath = this.renderPath(this.props.relPath);
+ const newPath = this.renderPath(this.props.newPath);
+ return {oldPath} → {newPath};
+ } else {
+ return this.renderPath(this.props.relPath);
+ }
+ }
+
+ renderPath(filePath) {
+ const dirname = path.dirname(filePath);
+ const basename = path.basename(filePath);
if (dirname === '.') {
return {basename};
diff --git a/lib/views/multi-file-patch-view.js b/lib/views/multi-file-patch-view.js
index b8d46976f8..479434e8be 100644
--- a/lib/views/multi-file-patch-view.js
+++ b/lib/views/multi-file-patch-view.js
@@ -316,6 +316,7 @@ export default class MultiFilePatchView extends React.Component {
0}
diff --git a/test/views/file-patch-header-view.test.js b/test/views/file-patch-header-view.test.js
index 74f5111dd6..5cf5564823 100644
--- a/test/views/file-patch-header-view.test.js
+++ b/test/views/file-patch-header-view.test.js
@@ -60,6 +60,13 @@ describe('FilePatchHeaderView', function() {
assert.strictEqual(wrapper.find('.github-FilePatchView-title').text(), `Staged Changes for ${relPath}`);
});
});
+
+ it('renders title for a renamed file as oldPath → newPath', function() {
+ const oldPath = path.join('dir', 'a.txt');
+ const newPath = path.join('dir', 'b.txt');
+ const wrapper = shallow(buildApp({relPath: oldPath, newPath}));
+ assert.strictEqual(wrapper.find('.github-FilePatchView-title').text(), `${oldPath} → ${newPath}`);
+ });
});
describe('the button group', function() {