Skip to content

Test and fix stacked diffs in forks

Identified via #7473 (comment 1953958771).

It seems to create corrupt MRs when working with a fork. I created a repository ( https://gitlab.softwareheritage.org/swh/devel/vlorentz-test/), then forked it ( https://gitlab.softwareheritage.org/vlorentz/vlorentz-test/), then cloned the fork, and here is what I did in the CLI:

 dev@desktop5  ~/vlorentz-test   main ~/glab stack create
? New stack title? test stack
! warning: invalid characters have been replaced with dashes: test-stack
New stack created with title "test-stack".

 dev@desktop5  ~/vlorentz-test   main  echo foo > test-file
 dev@desktop5  ~/vlorentz-test   main  git add test-file
 dev@desktop5  ~/vlorentz-test   main ✚  ~/glab stack save
? How would you describe this change? add the test file
• test-stack: Saved with message: "add the test file".

 dev@desktop5  ~/vlorentz-test   dev-test-stack-5b337685  echo bar > test-file
 dev@desktop5  ~/vlorentz-test   dev-test-stack-5b337685 ●  ~/glab stack save   
? How would you describe this change? change the test file
• test-stack: Saved with message: "change the test file".

 dev@desktop5  ~/vlorentz-test   dev-test-stack-74f87791  ~/glab stack sync
| Syncingcould not run sync: error determining base repo: none of the git remotes configured for this repository point to a known GitLab host. Please use `glab auth login` to authenticate and configure a new host for glab.

Configured remotes: gitlab.softwareheritage.org. are you in a git repository?

 dev@desktop5  ~/vlorentz-test   dev-test-stack-74f87791  ~/glab auth login                                                        
? What GitLab instance do you want to log into? GitLab Self-hosted Instance
? GitLab hostname: gitlab.softwareheritage.org
? API hostname: gitlab.softwareheritage.org
- Logging into gitlab.softwareheritage.org
? How would you like to sign in? Token

Tip: you can generate a Personal Access Token here https://gitlab.softwareheritage.org/-/profile/personal_access_tokens?scopes=api,write_repository
The minimum required scopes are 'api' and 'write_repository'.
? Paste your authentication token: **************************
? Choose default git protocol SSH
? Choose host API protocol HTTPS
- glab config set -h gitlab.softwareheritage.org git_protocol ssh
✓ Configured git protocol
- glab config set -h gitlab.softwareheritage.org api_protocol https
✓ Configured API protocol
✓ Logged in as vlorentz
 dev@desktop5  ~/vlorentz-test   dev-test-stack-74f87791  ~/glab stack sync                                                        
? Which should be the base repository (used for e.g. querying issues) for this directory? swh/devel/vlorentz-test

• dev-test-stack-5b337685 needs a merge request. Creating it now.

/ Syncing
• Merge request created!

!1 add the test file (dev-test-stack-5b337685)
 https://gitlab.softwareheritage.org/swh/devel/vlorentz-test/-/merge_requests/1


• dev-test-stack-74f87791 needs a merge request. Creating it now.

/ Syncing
• Merge request created!

!2 change the test file (dev-test-stack-74f87791)
 https://gitlab.softwareheritage.org/swh/devel/vlorentz-test/-/merge_requests/2


• Sync finished!

This creates the MRs on the upstream repository (https://gitlab.softwareheritage.org/swh/devel/vlorentz-test/), but pushes the branches on the fork ( https://gitlab.softwareheritage.org/vlorentz/vlorentz-test/) Opening the first MR shows a grey "Merge request contains no changes" error (because the MR's branch is assumed to be in the upstream, but it's not):

Screen_Shot_2024-06-17_at_22.20.14-fullpage

opening the second MR shows a red "Can't show this merge request because the source branch dev-test-stack-74f87791 is missing from project swh/devel/vlorentz-test. Close this merge request or update the source branch." error (because neither the MR's branch nor the base branch are in the upstream). I also can't close the second MR:

Screen_Shot_2024-06-17_at_22.20.36-fullpage

Edited by Kai Armstrong
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information