Wrong source branch on create pull request

Issue #5 new
Vinicius Salvati Melquiades created an issue

Where I work, we follow the git-flow branching model, so our branches have the name feature/some-feature-name or release/2.0.0, etc. When I run the command to create the pull request, the source parameter in the querystring is wrong (eg: feature, it strips the / and everything after it), forcing me to pick the correct branch from the dropdown.

Comments (11)

  1. Ramiro Berrelleza repo owner

    Ah, I know what's going on, thanks for the report 👍 ! I updated the way branch names are parsed and released it on 0.3.4, it should fix the issue. Could you give it a shot?

  2. Vinicius Salvati Melquiades reporter

    Didn't work. I got the same result as before. I double checked if I was in the right version.

  3. Brian Branch

    Well essentially I'm getting this:

    https://bitbucket.org/rberrelleza/bitbucket-pull-requests.git/projects/rberrelleza/repos/bitbucket-pull-requests/pull-requests?create
    

    when it should be:

    https://bitbucket.org/rberrelleza/bitbucket-pull-requests/pull-requests/new
    

    If I were using the repo for this project

  4. Vinicius Salvati Melquiades reporter

    Worked for me. The branch name is not correct in the query string, and Bitbucket could find the branch.

    I'm not getting the same problem as Brian though. I never had that problem. Maybe it has something to do with the remote format? I'm using SSH as Brian seems to be using HTTPS. Could that have something to do with his problem?

  5. Ramiro Berrelleza repo owner

    @BrianBranch that URL format is supposed to be for bitbucket server, not sure why it's being picked up for the bitbucket.org URL. Can you check and see if bitbucket-pull-requests.serverURL is set on your vscode configuration?

    Also, which format are you using for your remote? SSH, HTTPS, GIT?

  6. jaaahmed Account Deactivated

    Hi, I’m facing the similar issues (404), looks like the path shown while creating a Bitbucket pullrequest isn’t correct..

    it swaps’s the projects/bitbucket

    while this is the correct path

    https://CompanyPath/bitbucket/projects/BS/repos/bs-sfdc-code/pull-requests?create

    the Bitbucket pull request command takes to this path giving 404 error

    https://CompanyPath/projects/bitbucket/bs/repos/bs-sfdc-code/pull-requests?create

    can u provide the right commands to set it and how do we execute - bitbucket-pull-requests-0.3.5-dev.1.vsix ?

  7. Lucas Dasso

    Hi!

    While the pull-request web page opens without error, I notice that, for my custom Bitbucket server (not on bitbucket.org server), the pull-request branch name need to include ref/head/ before the actual branch name in order to be auto selected on page load.

    I was unable to find any documentation to validate this requirement, nor I’m aware if this is something particular of my Bitbucket server.

    Original file: src/bitbucket.ts line 142

    return urljoin(url, `projects/${o}/repos/${repo}/pull-requests?create&sourceBranch=${branch}&t=1`);
    

    Fixed file: src/bitbucket.ts line 142:

    return urljoin(url, `projects/${o}/repos/${repo}/pull-requests?create&sourceBranch=refs%2Fheads%2F${branch}&t=1`);
    

    Best regards!

  8. Ramiro Berrelleza repo owner

    @Lucas Dasso which version of Bitbucket Server do you have? I’m trying to figure out if this is something that depends on the setup or the version.

    Maybe we can make this a configurable URL template or something, to fit the different URL shapes people are seeing?

  9. Lucas Dasso

    Hi Ramiro!,

    Please disregard my last comments, as that was not the real issue.

    Not sure if this apply for any system, but I’m using MacOS Catalina, and zsh as my terminal bash.

    Debugging the plugin I was able to get the ‘open’ command with the generated URL used with the browser, and all looks correct, and the URL works as expected if used directly in the browser.

    But, if I try to run the open command from the terminal, it fails with this message:

    desktop % open https://bitbucket.mockupsite.com/projects/abc/repos/my-repo-123/pull-requests?create&sourceBranch=myname%2Fbranch-name&t=1'
    zsh: parse error near &
    desktop %
    

    To fix it, I wrapped the URL in quotes on the `getRunCommand` function on platform.js script.

        function getRunCommand(url) {
            url = `'${url}'`;
            const platform = os.platform();
            if (platform === 'darwin') {
                return `open ${url}`;
            }
            if (platform === 'win32') {
                return `start "" "${url}"`;
            }
            // picked the command based on https://askubuntu.com/questions/8252/how-to-launch-default-web-browser-from-the-terminal
            return `xdg-open ${url}`;
        }
    

    Best regards!

  10. Ramiro Berrelleza repo owner

    oh that’s great @Lucas Dasso ! Do you want to send a PR? If not, I can go ahead and apply the changes, assuming is just the url part you mentioned.

  11. Log in to comment