Bitbucket server: unable to find a remote

Issue #4 new
Charles Christie created an issue

My codebucket configuration looks like this:

    "codebucket.bitbucketServerHosts": [{
        "gitHost": "http://username@jira.generaldigital.com:7990"
    }],
    "codebucket.issueTrackers": [{
        "host": "http://jira.generaldigital.com:8080",
        "projectKeys": [
            "NMSX"
        ],
        "type": "jira"
    }]

And my output from git remote -v:

origin  http://username@jira.generaldigital.com:7990/scm/sdx/main.git (fetch)
origin  http://username@jira.generaldigital.com:7990/scm/sdx/main.git (push)

I've omitted my username, but for reference our server simultaneously requires authentication and does not support https. For some reason, I can't get your extension to find our remote.

Comments (8)

  1. Patrick Streule repo owner

    @sonicbhoc what's the error message you get? Does it fail to open the PR or does it fail to find the remote?

    @JakubPawlinski sorry, I must have missed the notification for you comment on issue #2. What's the output of git remote -v in your case? Does it match stash.company.com:7990?

  2. Jakub Pawlinski

    from VScode when trying to"BitBucket: Open Pull Request" I'm getting "

    Unable to find a remote matching: bitbucket.org | http://stash.company.com:7990
    

    from git remote -v

    origin  https://jakub.pawlinski@stash.company.com/scm/team/project.git (fetch)
    origin  https://jakub.pawlinski@stash.company.com/scm/team/project.git (push)
    
  3. Andre Webster

    I had to change the regular expression so that it worked for Bitbucket Server, it couldn't match any of the hosts it evaluated - no idea if this causes an issue with the bitbucket.org lookup.

    public async findRemoteHost(): Promise<Host> {
        const remotes = await this.getRemoteList();
        const hosts = bitbucketHosts();
    
        for (const host of hosts) {
          const pattern = new RegExp(`(\\w+)\\s+(?:http(s)?)[:]\\/{2}(?:([\\w\\._]+)@)?(${escapeStringRegexp(host.gitHost)})\\/([\\w._]+(?:\\/[\\w._]+)+)(?:\\.git)(?:\\s+\\((.+)\\))?`);
    
          for (const remote of remotes) {
            const matches = pattern.exec(remote);
            if (matches) {
              const config: HostConfig = {
                name: matches[4],
                gitHost: host.gitHost,
                webHost: host.webHost,
                repo: matches[5]
              };
              switch (host.type) {
                case 'bitbucket':
                  return new BitbucketHost(config);
                case 'bitbucket-server':
                  return new BitbucketServerHost(config);
                default: throw new CodeBucketError(`Unknown host type: ${host.type}`);
              }
            }
          }
        }
    
        const candidates = hosts.map(host => host.gitHost).join(' | ');
        throw new CodeBucketError(`Unable to find a remote matching: ${candidates}`);
      }
    
  4. Jakub Pawlinski

    tried to apply your fix ,but failed :( my settings are:

        "codebucket.bitbucketServerHosts": [{
            "webHost": "https://stash.company.com",
            "gitHost": "http://stash.company.com:7990"
        }],
    

    I'm pretty new to .js so it maybe my fault entirely. hope @pstreule can act on this

  5. Patrick Streule repo owner

    Apologies for my inactivity here, I did not have much spare time lately. I'll take a closer look on the weekend and hope to push a fix then.

  6. Log in to comment