|
| 1 | +# Upgrading to GitProxy v2 |
| 2 | + |
| 3 | +This guide attempts to cover everything needed for a seamless upgrade from GitProxy v1 (`1.19.2`) to v2. |
| 4 | + |
| 5 | +Most errors will be related to invalid database records added in v1 - mainly in the `user` and `repo` databases. As of writing, database migration files are not provided. |
| 6 | + |
| 7 | +## Noteworthy changes and their consequences |
| 8 | + |
| 9 | +Two important breaking changes were made: |
| 10 | + |
| 11 | +### Associate commits by email |
| 12 | + |
| 13 | +Commits are no longer associated by Git's `user.name`. Now, they're associated by email. [#973](github.com/finos/git-proxy/pull/973) |
| 14 | + |
| 15 | +In practice, pushes that were working in v1 may be blocked in v2 due to the change in requirements. The user's GitProxy email must match the commit's email (Git's `user.email`). |
| 16 | + |
| 17 | +### Support for GitLab and other Git hosts |
| 18 | + |
| 19 | +Added support for Git hosts other than GitHub. Eliminated assumptions about GitHub as the Git repository host. [#1043](https://github.com/finos/git-proxy/pull/1043) |
| 20 | + |
| 21 | +Repositories are no longer identified by name, but by internal ID instead. This means that multiple forks of the same repo are now supported, as well as repos for any other Git host (GitLab, etc.). |
| 22 | + |
| 23 | +However, as URL parsing is more strict, pushing to previously added GitHub repos may result in errors. |
| 24 | + |
| 25 | +## Troubleshooting typical errors |
| 26 | + |
| 27 | +Most of these errors can be easily **fixed by simply accessing the UI** to delete the offending repository, add it again, and restore all the allowed users. Manually editing the database entries is not recommended, but nevertheless a valid solution. |
| 28 | + |
| 29 | +If you encounter any errors not on this guide, feel free to [open a discussion](https://github.com/finos/git-proxy/discussions). |
| 30 | + |
| 31 | +### Errors when pushing to a repo that was working in v1: |
| 32 | + |
| 33 | +#### fatal: <repo-url>/info/refs not valid: is this git repository? |
| 34 | + |
| 35 | +`git push` returns: |
| 36 | + |
| 37 | +``` |
| 38 | +fatal: <repo-url>/info/refs not valid: is this git repository? |
| 39 | +``` |
| 40 | + |
| 41 | +This error happens when pushing to GitProxy with a mismatched URL. |
| 42 | + |
| 43 | +In v1, Git URLs without the trailing `.git` were considered valid: |
| 44 | + |
| 45 | +``` |
| 46 | +"url": "https://github.com/my-org/my-repo" |
| 47 | +``` |
| 48 | + |
| 49 | +In v2, URLs are automatically formatted when adding a repo. **Repos added in v1 must be edited or re-added to fix this error**: |
| 50 | + |
| 51 | +``` |
| 52 | +"url": "https://github.com/my-org/my-repo.git" |
| 53 | +``` |
| 54 | + |
| 55 | +#### Your push has been blocked (<email> is not allowed to push on repo <repo-url>) |
| 56 | + |
| 57 | +`git push` returns: |
| 58 | + |
| 59 | +``` |
| 60 | +Your push has been blocked (<email> is not allowed to push on repo <repo-url>) |
| 61 | +``` |
| 62 | + |
| 63 | +This error occurs when pushing to GitProxy without being in the `canPush` list. This error can also occur when no GitProxy users match the given email. |
| 64 | + |
| 65 | +In v1, authorised users were matched based on `gitAccount` (which was actually the Git `user.name` and mistakenly being used as the GitHub username in the UI): |
| 66 | + |
| 67 | +``` |
| 68 | +"users":{"canPush":["John Doe"],"canAuthorise":["John Doe","admin"]} |
| 69 | +``` |
| 70 | + |
| 71 | +In v2, authorised users are identified by their GitProxy username. The email associated with the push (Git `user.email`) must match their GitProxy email: |
| 72 | + |
| 73 | +Repo data: |
| 74 | + |
| 75 | +``` |
| 76 | +{"users":{"canPush":["johndoe123"],"canAuthorise":["johndoe123","admin"]"}, ...}` |
| 77 | +``` |
| 78 | + |
| 79 | +User data: |
| 80 | + |
| 81 | +``` |
| 82 | +{"username":"johndoe123","gitAccount":"<does-not-matter>","email":"<email>", ...} |
| 83 | +``` |
| 84 | + |
| 85 | +This is easily **solved by removing and re-adding the users from the dropdown list** in the UI (in the repository details page). |
0 commit comments