swingbit / jira2gitlab

Migrate Jira projects into a Gitlab instance
MIT License
20 stars 11 forks source link

User(s) with existing admin rights incorrectly set to non-admin after import #7

Closed caseybea closed 2 years ago

caseybea commented 2 years ago

The script as written (when allowed to) temporarily grants admin rights to users so that timestamps can be set properly. Clearly needed, and a cool way to handle this.

Unfortunately, the script does not check for what rights the user HAD prior to the import. If a user had admin rights beforehand, that user is incorrectly reset to non--admin when the script finishes.

swingbit commented 2 years ago

@caseybea could you please test the change above?

caseybea commented 2 years ago

Yes will test the new code immediately.

caseybea commented 2 years ago

Whoops! So, unfortunately the patch/fix did not work; and in fact ended up leaving everyone that didn't have admin rights with the admin rights.... so now when the export/import fiished, instead of adding admin rights back to a small number of people, I had to go in and REMOVE admin rights from a much larger population :-(

Screen log from the export below showing the issue with the admin rights. It errors out trying to reset the users.

Resetting user privileges..

[ERROR] Could not reset priviledges:

An error occurred while reverting the admin status of Gitlab users. IMPORTANT: The following users should be revoked the admin status manually: [ "moium", "kawoods", "llamers", "dabell", "bskrade", "kthorat", "mastake", "wjin", "motutaj", "kosinski", "rswanson", "mtutaj", "jthota", "wdemos", "kormoua" ]

[root@butler jira2gitlab-main]#

swingbit commented 2 years ago

ouch, sorry about that. Perhaps I did something wrong with the last commit. Checking.

swingbit commented 2 years ago

I reverted the last commit. I think it should work now. Sorry but I don't have a test environment up, at the moment.

To test this, you can interrupt the script after a few minutes and check if it behaved correctly regarding the users.

caseybea commented 2 years ago

OK will try.

caseybea commented 2 years ago

Nope. totally new error. (we're ok here, I am willing to help keep trying!). Note I am wiping out my issues and starting with a blank project every time and also nuking the pickle file.

[INFO] #1/2304 Migrating Jira issue ITS-1 ... Traceback (most recent call last): File "./jira2gitlab.py", line 886, in migrate_project(jira_project, gitlab_project) File "./jira2gitlab.py", line 453, in migrate_project gl_assignee = [resolve_login(issue['fields']['assignee']['name'])['id']] File "./jira2gitlab.py", line 281, in resolve_login return gl_user UnboundLocalError: local variable 'gl_user' referenced before assignment

Migration failed

Resetting user privileges..

swingbit commented 2 years ago

Of course. I hope it's fixed now.

caseybea commented 2 years ago

Sorry for the delay- boss had me on something else for a bit.

Confirmed- the final fix did the trick! Thank you.