Skip to content

Commit

Permalink
Display the merge message in index viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
pvigier committed Mar 13, 2019
1 parent 45df59c commit 1fd6a36
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/renderer/components/index-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,21 @@ export class IndexViewer extends React.PureComponent<IndexViewerProps, IndexView
this.handleSubmit = this.handleSubmit.bind(this);
}

componentDidMount() {
async componentDidMount() {
this.getPatches();
if (this.props.repoState === RepoState.Merge) {
this.setState({
summary: await this.props.repo.getMergeMessage()
});
}
}

async componentDidUpdate(prevProps: IndexViewerProps) {
if (prevProps.repoState !== this.props.repoState) {
this.setState({
summary: this.props.repoState === RepoState.Merge ? await this.props.repo.getMergeMessage() : ''
});
}
}

handleUnstagedPatchSelect(patch: Git.ConvenientPatch) {
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/helpers/repo-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,18 @@ export class RepoWrapper {
}
}

async getMergeMessage() {
return new Promise<string>((resolve, reject) => {
fs.readFile(Path.join(this.path, 'MERGE_MSG'), (error, data) => {
if (!error) {
resolve(data.toString().split('\n')[0]);
} else {
reject(error);
}
});
});
}

async finishMerge(message: string) {
try {
const author = this.getSignature();
Expand Down

0 comments on commit 1fd6a36

Please sign in to comment.