mirror of
https://github.com/desktop/desktop
synced 2024-09-19 08:02:22 +00:00
Merge pull request #11345 from desktop/clear-after-commit-fix
Fix summary & description fields deleting user's text (sometimes) after a commit
This commit is contained in:
commit
43c7e3acde
|
@ -2376,14 +2376,39 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
|
||||
const gitStore = this.gitStoreCache.get(repository)
|
||||
|
||||
const result = await this.isCommitting(repository, () => {
|
||||
return gitStore.performFailableOperation(async () => {
|
||||
return this.withIsCommitting(repository, async () => {
|
||||
const result = await gitStore.performFailableOperation(async () => {
|
||||
const message = await formatCommitMessage(repository, context)
|
||||
return createCommit(repository, message, selectedFiles)
|
||||
})
|
||||
return createCommit(repository, message, selectedFiles) !== undefined
|
||||
})
|
||||
|
||||
if (result) {
|
||||
await this._recordCommitStats(
|
||||
gitStore,
|
||||
repository,
|
||||
state,
|
||||
context,
|
||||
files
|
||||
)
|
||||
|
||||
await this._refreshRepository(repository)
|
||||
await this.refreshChangesSection(repository, {
|
||||
includingStatus: true,
|
||||
clearPartialState: true,
|
||||
})
|
||||
}
|
||||
|
||||
return result || false
|
||||
})
|
||||
}
|
||||
|
||||
private async _recordCommitStats(
|
||||
gitStore: GitStore,
|
||||
repository: Repository,
|
||||
repositoryState: IRepositoryState,
|
||||
context: ICommitContext,
|
||||
files: readonly WorkingDirectoryFileChange[]
|
||||
) {
|
||||
this.statsStore.recordCommit()
|
||||
|
||||
const includedPartialSelections = files.some(
|
||||
|
@ -2407,7 +2432,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
this.statsStore.recordCommitToEnterprise()
|
||||
}
|
||||
|
||||
const { commitAuthor } = state
|
||||
const { commitAuthor } = repositoryState
|
||||
if (commitAuthor !== null) {
|
||||
const commitEmail = commitAuthor.email.toLowerCase()
|
||||
const attributableEmails = getAttributableEmailsFor(account)
|
||||
|
@ -2451,15 +2476,6 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
await this._refreshRepository(repository)
|
||||
await this.refreshChangesSection(repository, {
|
||||
includingStatus: true,
|
||||
clearPartialState: true,
|
||||
})
|
||||
}
|
||||
|
||||
return result || false
|
||||
}
|
||||
|
||||
/** This shouldn't be called directly. See `Dispatcher`. */
|
||||
|
@ -3562,14 +3578,14 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
})
|
||||
}
|
||||
|
||||
private async isCommitting(
|
||||
private async withIsCommitting(
|
||||
repository: Repository,
|
||||
fn: () => Promise<string | undefined>
|
||||
): Promise<boolean | undefined> {
|
||||
fn: () => Promise<boolean>
|
||||
): Promise<boolean> {
|
||||
const state = this.repositoryStateCache.get(repository)
|
||||
// ensure the user doesn't try and commit again
|
||||
if (state.isCommitting) {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
this.repositoryStateCache.update(repository, () => ({
|
||||
|
@ -3578,8 +3594,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
|
|||
this.emitUpdate()
|
||||
|
||||
try {
|
||||
const sha = await fn()
|
||||
return sha !== undefined
|
||||
return await fn()
|
||||
} finally {
|
||||
this.repositoryStateCache.update(repository, () => ({
|
||||
isCommitting: false,
|
||||
|
|
|
@ -776,7 +776,10 @@ export class ChangesList extends React.Component<
|
|||
selectedRows={this.state.selectedRows}
|
||||
selectionMode="multi"
|
||||
onSelectionChanged={this.props.onFileSelectionChanged}
|
||||
invalidationProps={this.props.workingDirectory}
|
||||
invalidationProps={{
|
||||
workingDirectory: this.props.workingDirectory,
|
||||
isCommitting: this.props.isCommitting,
|
||||
}}
|
||||
onRowClick={this.props.onRowClick}
|
||||
onScroll={this.onScroll}
|
||||
setScrollTop={this.props.changesListScrollTop}
|
||||
|
|
Loading…
Reference in a new issue