Allow git pull/push on project redirects

Description

Problem: Renaming or transferring a project/group/user causes existing git urls to break, which breaks anything depending on them.

Current behavior

  • Create project foo in GitLab
  • Clone project foo to local machine
  • Rename project foo to bar
  • Attempt pull or push locally
  • You get rejected, with an error message that says the project was renamed and to update your remote url

Proposal

Let old git urls of redirected projects continue to work until/unless overridden. Display a redirect warning message.

Acceptance Criteria

  • Create project foo in GitLab
  • Clone project foo to local machine
  • Rename project foo to bar
  • Attempt pull or push locally
  • The pull or push works, with a warning message that says the project was renamed and to update your remote url

Links / references

GitHub behavior on username change: https://help.github.com/articles/what-happens-when-i-change-my-username/#repository-references

GitHub repo redirects: https://github.com/blog/1508-repository-redirects-are-here

This has been the case for 4 years, hence it is reasonable to assume that this behavior is safe enough. Our reasoning for not redirecting git requests was that it may be unsafe in case someone else claims a vacated username or group name.

Use cases

From https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10370#note_35541230:

If you have repo configured in code to pull a branch regularly from a repo and the group/repo got renamed

Feature checklist

Make sure these are completed before closing the issue, with a link to the relevant commit.

Edited by Michael Kozono