message: Fixed current branch and branch listing
diff: @@ -55,19 +55,38 @@ export class Repository {
  }
  async getCurrentBranch(): Promise<string> {
  - try {
  - const result = await this.svn.info(this.workspaceRoot);
  - const currentBranch = result.stdout
  - .match(/<url>(.*?)<\/url>/)[1]
  - .split("/")
  - .pop();
  - return currentBranch;
  - } catch (error) {
  - console.error(error);
  - return "";
  + const info = await this.svn.info(this.workspaceRoot);
  +
  + if (info.exitCode !== 0) {
  + throw new Error(info.stderr);
  + }
  +
  + const config = workspace.getConfiguration("svn");
  + const trunkLayout = config.get<string>("layout.trunk");
  + const branchesLayout = config.get<string>("layout.branches");
  + const tagsLayout = config.get<string>("layout.tags");
  +
  + const trees = [trunkLayout, branchesLayout, tagsLayout].filter(
  + x => x != null
  + );
  + const regex = new RegExp(
  + "<url>(.*?)/(" + trees.join("|") + ")(/([^/]+))?.*?</url>"
  + );
  +
  + const match = info.stdout.match(regex);
  +
  + if (match) {
  + if (match[4] && match[2] !== trunkLayout) {
  + return match[4];
  + }
  + if (match[2]) {
  + return match[2];
  }
  }
  + return "";
  + }
  +
  async getRepoUrl() {
  const config = workspace.getConfiguration("svn");
  const trunkLayout = config.get<string>("layout.trunk");
  @@ -136,10 +155,9 @@ export class Repository {
  trees.push(tagsLayout);
  }
  - for (let index in trees) {
  + for (const tree of trees) {
  promises.push(
  new Promise<string[]>(async resolve => {
  - const tree = trees[index];
  const branchUrl = repoUrl + "/" + tree;
  const result = await this.svn.list(branchUrl);
  @@ -153,6 +171,7 @@ export class Repository {
  .trim()
  .replace(/\/|\\/g, "")
  .split(/[\r\n]+/)
  + .filter((x: string) => !!x)
  .map((i: string) => tree + "/" + i);
  resolve(list);
  