Import Repository by Url, different behavior between version 0.36.3 and 0.38.0
Summary
I've just checked the behavior of 'import Repository by Url' when creating a new project via web interface. One can import a Git or a Hg origin url but the user must ensure the Vcs type set is of the same type as the origin url.
On both version 0.36.3 and 0.38-pre this works fine when both url and Vcs type are correctly set, but behavior is not the same on some corner cases.
In both versions with Mercurial Vcs type set when the origin url isn't a Mercurial one or is 404, an empty project is created.
Steps to reproduce
- Create a new project
- Choose 'import repository by url'
On the import form try the following combinations:
Url | Url Type | Vcs type |
---|---|---|
https://github.com/octocat/Hello-World | Git | Git |
https://github.com/octocat/Hello-World | Git | Mercurial |
https://github.com/octocat/Hello-World.git | Git | Git |
https://github.com/octocat/Hello-World.git | Git | Mercurial |
https://hg.sr.ht/~scoopta/wlrobs | Mercurial | Mercurial |
https://hg.sr.ht/~scoopta/wlrobs | Mercurial | Git |
https://github.com/404/Hello-404 | 404 | Git |
https://github.com/404/Hello-404 | 404 | Mercurial |
Example Project
On current Heptapod Version 0.36.3 here are some of the resulting imported projects:
- Git, Git, https://foss.heptapod.net/heptapod/testing-projects/test-import-0.36.3-git-git-Hello-World
- Git, Mercurial, https://foss.heptapod.net/heptapod/testing-projects/test-import-0-36-3-git-hg-Hello-World
- Git url with dot git suffix, Mercurial, https://foss.heptapod.net/heptapod/testing-projects/test-import-0-36-3-git-dot-git-hg-Hello-World
- Mercurial, Mercurial, https://foss.heptapod.net/heptapod/testing-projects/test-import-0-36-3-hg-hg-wlrobs
- Mercurial, Git, https://foss.heptapod.net/heptapod/testing-projects/test-import-0-36-3-hg-git-wlrobs
- 404, Git, https://foss.heptapod.net/heptapod/testing-projects/test-import-0-36-03-404-git-Hello-404
- 404, Mercurial, https://foss.heptapod.net/heptapod/testing-projects/test-import-0-36-3-404-hg-Hello-404
What is the current bug behavior?
On both version 0.36.3 and 0.38-pre, with 404 url the behavior between Mercurial and Git differs. Both create the project, Mercurial creates an empty repository when it should not.
When an url is valid but the Vcs type set mismatch, the behavior between Git and Mercurial is not the same.
The only "regression" I found between versions 0.36.3 and 0.38-pre is quite funny and I guess its an expected one. On 0.36.3 when you add .git suffix to a valid Git Url and set the Vcs type as Mercurial, it does work and automatically convert git repository to Mercurial. On 0.38-pre it does behave the same, create a project, an empty repository and report an error in import history.
Error importing repository https://github.com/octocat/Hello-World.git into root/git-dot-git-hg-Hello-World - Gitlab::Mercurial::HgitalyRepository import_repository for [FILTERED] into [FILTERED] import failed
What is the expected correct behavior?
The current behavior of Gitlab against 404 when expecting Git url is to create the project but without a repository. With Mercurial as Vcs type, it should follow the same pattern, but instead it creates an empty repository.
I guess the minimum needed with Mercurial case is to behave like Git.
For valid url but mismatching type I guess the best is to detect and report mismatch to user.
Relevant logs and/or screenshots
I can provide screen shots if needed:
Heptapod 0.38-pre
OK, Existing Git origin url with Vcs type Git, https://github.com/octocat/Hello-World.git, https://github.com/octocat/Hello-World
OK, 404 Git origin url with type Git, https://github.com/octocat/Hello-World-with-a-typo.git, https://github.com/octocat/Hello-World.gut (Ends with an error message, no repository created as expected. The repository could not be imported. Error importing repository https://github.com/octocat/Hello-World-with-a-typo.git into root/Hello-World-with-a-typo - 13:creating repository: cloning repository: exit status 128, stderr: "fatal: could not read Username for [FILTERED] terminal prompts disabled\n".
KO, Existing Git origin url with Vcs type Hg, https://github.com/octocat/Hello-World.git (It does create a Hg repository but empty. It also generates an error not exposed to user at the end of import but that can be seen through import history. Error importing repository https://github.com/octocat/Hello-World.git into root/Hello-World-from-hg - Gitlab::Mercurial::HgitalyRepository import_repository for [FILTERED] into [FILTERED] import failed)
KO, 404 origin url with Vcs type Hg, https://github.com/octocat/Hello-World-with-a-typo (It does create a Hg repository but empty. It also generates an error not exposed to user at the end of import but that can be seen through import history. Error importing repository https://github.com/octocat/Hello-World-with-a-typo into root/Hello-World-with-a-typo-as-hg - Gitlab::Mercurial::HgitalyRepository import_repository for [FILTERED] into [FILTERED] import failed
OK, Existing Hg origin url with Vcs type Hg, https://foss.heptapod.net/heptapod/testing-projects/hg-website-imported, https://foss.heptapod.net/heptapod/testing-projects/hg-website-imported.hg, https://hg.sr.ht/~scoopta/wlrobs, (Everything fine except the url shown in the import in progress screen which indicates hg pull https://foss.heptapod.net/heptapod/testing-projects/hg-website-imported which looks fine but does not work if launched in a terminal as the one showed in Git cases)
KO, Existing Hg origin url with Vcs type Git, https://hg.sr.ht/~scoopta/wlrobs, ((It does a create project but without repository and without Vcs Type. The resulting 'No repository' page show a button to create an empty repository or to import a repository into this project. It also generates an error not exposed to at the end of import but that can be seen through import history. Error importing repository https://hg.sr.ht/~scoopta/wlrobs into root/wlrobs-hg-git-01 - 13:creating repository: cloning repository: exit status 128, stderr: "fatal: repository [FILTERED] not found\n".)
Details about the Heptapod instance where the bug occurs
0.36.3 on https://foss.heptapod.net 0.38-pre on Docker environment