Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I view the pull request URL for the current branch?

After pushing a change, I see text like this:

Writing objects: 100% (5/5), 478 bytes | 239.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote:
remote: Create pull request for my-branch => master-branch
remote:   https://bitbucket.org/my-company/repo/pull-requests/12345

But if I don't make a PR at that time, and the text scrolls out of view, that URL is gone. How can I simply generate or re-view that URL without making a change and committing/pushing again?

like image 416
Grid Trekkor Avatar asked Mar 08 '18 21:03

Grid Trekkor


People also ask

How do I find a pull request from a branch?

Once you've committed changes to your local copy of the repository, click the Create Pull Request icon. Check that the local branch and repository you're merging from, and the remote branch and repository you're merging into, are correct. Then give the pull request a title and a description. Click Create.

How do I share a pull request link?

Under your repository name, click Pull requests. In the list of pull requests, click the pull request that you'd like to link to an issue. In the right sidebar, in the "Development" section click . Click the issue you want to link to the pull request.

Can I open pull request from command line?

Now you can use the gpr command straight from your command line to automatically open a page to compare two remote branches and start the Pull Request process automatically!


2 Answers

I was able to generate the URL using a batch file like this:

@echo off

setlocal 
for /f "tokens=*" %%a in ( 
    'git rev-parse --abbrev-ref HEAD'
) do ( 
    set branch=%%a
    set url=https://bitbucket.org/my-company/repo/pull-requests/new?source=%%a^^^&t=1
) 

echo %url%
endlocal 

It simply grabs the current git branch and puts in a string, then echoes the string.

like image 200
Grid Trekkor Avatar answered Sep 20 '22 15:09

Grid Trekkor


This pull request URL is not a git feature but a message generated by a hook script on the BitBucket server.

On a BitBucket server, you can disable it globally with: How do I disable the remote create pull request message when pushing changes?. On the BitBucket cloud you cannot disable it.

One soultion to obtain this message would be to simulate a git pull with the --dry-run option, such as :

git pull --dry-run 

but if this is not enough to trigger the hook, probably that the only way is to go through the BitBucket web interface.

like image 21
Ortomala Lokni Avatar answered Sep 21 '22 15:09

Ortomala Lokni