Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,31 @@ export class SvnCommands implements IDisposable {
}

@command("svn.promptAuth", { repository: true })
async promptAuth(repository: Repository) {
repository.username = await window.showInputBox({
async promptAuth(repository: Repository): Promise<boolean> {
const username = await window.showInputBox({
placeHolder: "Svn repository username",
prompt: "Please enter your username"
prompt: "Please enter your username",
value: repository.username
});

repository.password = await window.showInputBox({
if(username === undefined) {
return false;
}

const password = await window.showInputBox({
placeHolder: "Svn repository password",
prompt: "Please enter your password"
prompt: "Please enter your password",
password: true
});

if(username === undefined) {
return false;
}

repository.username = username;
repository.password = password;

return true;
}

@command("svn.commitWithMessage", { repository: true })
Expand Down Expand Up @@ -168,7 +183,7 @@ export class SvnCommands implements IDisposable {
repository.inputBox.value = "";
} catch (error) {
console.error(error);
window.showErrorMessage(error);
window.showErrorMessage("Unable to commit");
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class Repository {
public isIncomplete: boolean = false;
public needCleanUp: boolean = false;

private lastPromptAuth?: Thenable<void | undefined>;
private lastPromptAuth?: Thenable<boolean | undefined>;

private _onDidChangeRepository = new EventEmitter<Uri>();
readonly onDidChangeRepository: Event<Uri> = this._onDidChangeRepository
Expand Down Expand Up @@ -688,16 +688,16 @@ export class Repository {
);
}

async promptAuth() {
async promptAuth(): Promise<boolean | undefined> {
// Prevent multiple prompts for auth
if (this.lastPromptAuth) {
await this.lastPromptAuth;
return;
return await this.lastPromptAuth;
}

this.lastPromptAuth = commands.executeCommand("svn.promptAuth");
await this.lastPromptAuth;
const result = await this.lastPromptAuth;
this.lastPromptAuth = undefined;
return result;
}

onDidSaveTextDocument(document: TextDocument) {
Expand Down Expand Up @@ -774,7 +774,10 @@ export class Repository {
err.svnErrorCode === SvnErrorCodes.AuthorizationFailed &&
attempt <= 3
) {
await this.promptAuth();
const result = await this.promptAuth();
if (!result) {
throw err;
}
} else {
throw err;
}
Expand Down
4 changes: 4 additions & 0 deletions src/svn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function getSvnErrorCode(stderr: string): string | undefined {
}
}

if (/No more credentials or we tried too many times/.test(stderr)) {
return SvnErrorCodes.AuthorizationFailed;
}

return void 0;
}

Expand Down