Github Importer not retaining the original author (Documentation update)
Summary
One of our prospects is encountering an issue with regards to Github import. Using Github importer doesn't retain the author of the pull request and issues imported. The customer is encountering this with Github EE but I can reproduce this when using Github.com
Steps to reproduce
This test requires two separate Github account (User A, and User B)
- Integrate your GitLab instance with GitHub.
- Create both users that have a Github account with the proper email address.
- Create a test project in Github.com as User A.
- Create a pull request with User B.
- Login the GitLab instance using User A.
- Import the test project using Github integration
- Check the author of the imported pull request. The author is the one that imported the project even though User B also exists in GitLab with the proper email address.
This is stated in our documentation: https://docs.gitlab.com/ee/user/project/import/github.html#how-it-works
For this association to succeed, each GitHub author and assignee in the repository must meet one of the following conditions prior to the import:
Have previously logged in to a GitLab account using the GitHub icon.
Have a GitHub account with a primary email address that matches their GitLab account’s email address.
What is the current bug behavior?
The one that imported the project is the author of the imported pull request.
What is the expected correct behavior?
Author should be retain.
Possible fixes
I also did some test and this code:
def user(username)
with_rate_limit { octokit.user(username) }
end
Is returning the output with email
set to nil
. Similar to this one: https://stackoverflow.com/questions/62513459/user-email-is-nil-octokit-github-api
I verified this by running the following:
- Open a Rails console on a separate terminal:
sudo gitlab-rails console
- Import a new project from Github.
- During the import process, run the following commands in the Rails console:
project = Project.last
token = project.import_data&.credentials&.fetch(:user)
client = Gitlab::GithubImport::Client.new(token, parallel: true)
user = client.user("<USERNAME>")
puts user.email