Git with two remotes sources
uri200 opened this issue · comments
Hello
Thanks for that plugin
I am trying to configure it with my set up but I am not able to succedd
We have two different repositories configured to be able to push PRs. Origin points to our own fork, while upstream points to public repo.
╰─ git remote -v
origin git@github.com:uri200/magma.git (fetch)
origin git@github.com:uri200/magma.git (push)
upstream git@github.com:magma/magma.git (fetch)
upstream git@github.com:magma/magma.git (push)
I am trying to configure the plugin so the links are open in upstream
, but no matter how i configure this, it always open origin.
My sourcegraph.xml
looks as follows
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Config">
<option name="url" value="https://sourcegraph.com" />
<option name="defaultBranch" value="master" />
<option name="remoteUrlReplacements" value= "github.com/magma/magma" />
</component>
</project>
Am I missing something?
@uri200 I think you can archive this by replacing the name of the origin
repo owner with the one from upstream
.
Can you please change your existing sourcegraph.xml
to the following setting and let me know if this works for you?
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Config">
<option name="url" value="https://sourcegraph.com" />
<option name="defaultBranch" value="master" />
<option name="remoteUrlReplacements" value= "github.com/uri200 , github.com/magma" />
</component>
</project>
Hey @abeatrix thanks for your suggestion.
I think I tried that conviation too and it didn't work.
Just in case you are curious, here you have the links I get using that:
https://sourcegraph.com/-/editor?remote_url=git%40github.com%3Auri200%2Fmagma.git&branch=master&file=lte%2Fgateway%2Fpython%2Finteg_tests%2Fs1aptests%2Ftest_attach_detach.py&editor=JetBrains&version=v1.2.1&utm_product_name=IntelliJ+IDEA&utm_product_version=2021.2.2&start_row=27&start_col=28&end_row=27&end_col=28
results into this:
https://sourcegraph.com/github.com/uri200/magma/-/blob/lte/gateway/python/integ_tests/s1aptests/test_attach_detach.py?utm_product_name=IntelliJ+IDEA&utm_product_version=IntelliJ+IDEA#L28:29
This is what I would expect:
https://sourcegraph.com/github.com/magma/magma/-/blob/lte/gateway/python/integ_tests/s1aptests/test_attach_detach.py?L7=&utm_product_name=IntelliJ+IDEA&utm_product_version=IntelliJ+IDEA#L28:30
Content of the file (just in case):
╭─ ~/magma/.idea | on chore_federated_lte_test_1 *47 !3 ?3 ✔ | took 14s | at staging/orc8r ○ | at 16:54:18
╰─ cat sourcegraph.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Config">
<option name="url" value="https://sourcegraph.com" />
<option name="defaultBranch" value="master" />
<option name="remoteUrlReplacements" value= "github.com/uri200, github.com/magma" />
</component>
</project>
@uri200 I'm sorry that didn't work for you. It looks like I am able to reproduce the issue!
Can you try to update your XML file to:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Config">
<option name="url" value="https://sourcegraph.com" />
<option name="defaultBranch" value="master" />
<option name="remoteUrlReplacements" value="github.com/uri200, github.com/magma, github.com:uri200, github.com:magma" />
</component>
</project>
Removing the sourcegraph.xml
file to use the sourcegraph-jetbrains.properties
file also works for me:
url = https://sourcegraph.com/
defaultBranch = master
remoteUrlReplacements = github.com/uri200, github.com/magma, github.com/magma, github.com:uri200
Thanks @abeatrix , that worked for me, now I am getting the proper link
https://sourcegraph.com/github.com/magma/magma/-/blob/lte/gateway/python/integ_tests/s1aptests/test_attach_detach.py?utm_product_name=IntelliJ+IDEA&utm_product_version=IntelliJ+IDEA#L36:50
BTW, how does remoteUrlReplacements
work? Does it replace pairs?
github.com/uri200 -> github.com/magma,
github.com:uri200 -> github.com:magma"
That's correct! remoteUrlReplacements
works in pairs.