Project import does not reconcile group labels with project labels
### Summary
While importing a tar.gz export file (originally exported from gitlab.com) the import fails on a specific namespace.
### Steps to reproduce
- Import a repo from gitlab.com using gitlab.com importer -> mygroup/myrepo
- (Import succeeds but issues are all out of order, attachements and issue comments are imported incorrectly, issue labels missing entirely.
- Export the gitlab.com repository using the gilab exporter (emails the tar.gz file)
- Import the tar.gz file into a group namespace under the name mygroup/myrepo2
- (Import succeeds)
- Delete mygroup/myrepo2 and mygroup/myrepo
- Import the same tar.gz file used on the first import, this time under the name mygroup/myrepo
- Import fails with error message:`
The repository could not be imported.
Validation failed: Title already exists at group level for xxxxxxx. Please choose another one.
Git repository URL
https://username:password@gitlab.company.com/group/project.git`
- Import the same tar.gz file under the name mygroup/myrepo2 (same error message as before)
- Import under a different namespace (for example myuser/myrepo) succeeds (however transfer to group namespace messes up issue uploads/images/attachments)
### What is the current *bug* behavior?
Import of tar.tz results in error:`
The repository could not be imported.
Validation failed: Title already exists at group level for xxxxxx. Please choose another one.
Git repository URL
https://username:password@gitlab.company.com/group/project.git`
### What is the expected *correct* behavior?
Import should succeed (as it did the first time)
### Output of checks
This happend on a local gitlab-ce server
#### Results of GitLab environment info
`sudo gitlab-rake gitlab:env:info`
```
System information
System: Ubuntu 16.04
Current User: git
Using RVM: no
Ruby Version: 2.3.3p222
Gem Version: 2.6.6
Bundler Version:1.13.7
Rake Version: 10.5.0
Redis Version: 3.2.5
Sidekiq Version:4.2.7
GitLab information
Version: 8.17.3
Revision: f0c970e
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: https://--------------
HTTP Clone URL: https://----------------/some-group/some-project.git
SSH Clone URL: git@----------------:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 4.1.1
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
```
#### Results of GitLab application Check
`sudo gitlab-rake gitlab:check SANITIZE=true`)
Checking GitLab Shell ...
GitLab Shell version >= 4.1.1 ? ... OK (4.1.1)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ...
3/5 ... ok
3/6 ... ok
3/7 ... ok
3/8 ... ok
3/9 ... ok
3/10 ... ok
3/11 ... ok
3/12 ... ok
3/13 ... ok
3/14 ... ok
3/15 ... ok
3/16 ... ok
3/17 ... ok
3/18 ... ok
3/19 ... ok
2/32 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
Send ping to redis server: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ...
3/5 ... yes
3/6 ... yes
3/7 ... yes
3/8 ... yes
3/9 ... yes
3/10 ... yes
3/11 ... yes
3/12 ... yes
3/13 ... yes
3/14 ... yes
3/15 ... yes
3/16 ... yes
3/17 ... yes
3/18 ... yes
3/19 ... yes
2/32 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.3)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 2.7.3 ? ... yes (2.10.2)
Active users: 11
Checking GitLab ... Finished
### Possible fixes
The "broken" gitlab.com imports (missing labels and so on) and the issue link/image/attachment failures are a separate issue and might have corresponding bug reports that fit better. The import issue and the described error seem more like a bug than an uncompleted feature.
issue