Skip to content

Commit

Permalink
use IApplicationShell to show failures on actionRef and actionCommit …
Browse files Browse the repository at this point in the history
…requests
  • Loading branch information
ole1986 committed Feb 24, 2020
1 parent 8b9b477 commit b5285f0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions browser/src/actions/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const actionCommit = (logEntry: LogEntry, name: string = '', value: strin
break;
}
dispatch(updateCommitInList(result.data as LogEntry));
}).catch(ex => {
dispatch(updateCommitInList(logEntry));
});
};
};
Expand All @@ -63,6 +65,8 @@ export const actionRef = (logEntry: LogEntry, ref: Ref, name: string = '') => {

dispatch(getBranches());
dispatch(updateCommitInList(logEntry));
}).catch(ex => {
dispatch(updateCommitInList(logEntry));
});
};
};
Expand Down
12 changes: 10 additions & 2 deletions src/adapter/repository/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ export class Git implements IGitService {
}

public async createBranch(branchName: string, hash: string): Promise<void> {
await this.repo.createBranch(branchName, false, hash);
try {
await this.repo.createBranch(branchName, false, hash);
} catch (ex) {
throw ex.stderr;
}
}

public async createTag(tagName: string, hash: string): Promise<any> {
Expand All @@ -316,7 +320,11 @@ export class Git implements IGitService {
}

public async removeBranch(branchName: string) {
await this.repo.deleteBranch(branchName);
try {
await this.repo.deleteBranch(branchName);
} catch (ex) {
throw ex.stderr;
}
}

public async removeRemoteBranch(remoteBranchName: string) {
Expand Down
5 changes: 5 additions & 0 deletions src/server/apiController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import { CommitDetails, FileCommitDetails } from '../common/types';
import { IServiceContainer } from '../ioc/types';
import { Avatar, CommittedFile, IGitService, IGitServiceFactory, LogEntries, LogEntriesResponse, LogEntry, Ref, RefType } from '../types';
import { IApiRouteHandler } from './types';
import { IApplicationShell } from '../application/types';

// tslint:disable-next-line:no-require-imports no-var-requires

@injectable()
export class ApiController implements IApiRouteHandler {
private readonly commitViewer: IGitCommitViewDetailsCommandHandler;
private readonly applicationShell: IApplicationShell;
constructor(private app: Express,
private gitServiceFactory: IGitServiceFactory,
private serviceContainer: IServiceContainer,
private commandManager: ICommandManager) {

this.commitViewer = this.serviceContainer.get<IGitCommitViewDetailsCommandHandler>(IGitCommitViewDetailsCommandHandler);
this.applicationShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);

this.app.get('/log', this.handleRequest(this.getLogEntries.bind(this)));
this.app.get('/branches', this.handleRequest(this.getBranches.bind(this)));
Expand Down Expand Up @@ -167,6 +170,7 @@ export class ApiController implements IApiRouteHandler {
}
response.status(200).send('');
} catch (err) {
this.applicationShell.showErrorMessage(err);
response.status(500).send(err);
}
}
Expand Down Expand Up @@ -204,6 +208,7 @@ export class ApiController implements IApiRouteHandler {
}
response.status(200).send(logEntry);
} catch(err) {
this.applicationShell.showErrorMessage(err);
response.status(500).send(err);
}
}
Expand Down

0 comments on commit b5285f0

Please sign in to comment.