Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Add GitLab issue tracker to YouTrack migration script #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yavin5
Copy link

@yavin5 yavin5 commented Aug 22, 2018

Added the GitLab issue tracker migration script.

  • Adapted from github2youtrack.py
  • Tested and verified against GitLab 11.x, API v4, multiple projects with hundreds of real issues.
  • Includes migrating comments, but not attachments on comments yet.
  • Fixes a date format issue bug in cvs2youtrack.py by clipping milliseconds field out of date strings that come from GitLab. This shouldn't harm other migrators.

yavin5 added 2 commits August 22, 2018 18:47
- Adapted from github2youtrack.py
- Tested and verified against GitLab 11.x, API v4, multiple projects with hundreds of real issues.
- Includes migrating comments, but not attachments on comments yet.
- Fixes a date format issue bug in cvs2youtrack.py by clipping milliseconds field out of date strings that come from GitLab.  This shouldn't harm other migrators.
@pyriand3r
Copy link

pyriand3r commented Jun 4, 2019

Hi, was trying your script today. I downloaded the gitlab2youtrack.py and executed it by hand because it is still not merged.

I installed the scripts and youtrack package both with pip first and patched the csv2youtrack.py afterwards according to this pull request. Yet i get an error exactly at this point:

Traceback (most recent call last):
  File "gitlab2youtrack.py", line 283, in <module>
    main()
  File "gitlab2youtrack.py", line 148, in main
    csv2youtrack.csv2youtrack(params)
  File "/home/gabriel/projects/gitlab/youtrack-python-scripts/youtrackutils/csv2youtrack.py", line 245, in csv2youtrack
    importer.import_csv()
  File "/home/gabriel/projects/gitlab/youtrack-python-scripts/youtrackutils/csv2youtrack.py", line 275, in import_csv
    self.do_import(projects, new_projects_owner_login)
  File "/usr/lib/python2.7/site-packages/youtrack/youtrackImporter.py", line 30, in do_import
    self._import_issues(project_id)
  File "/usr/lib/python2.7/site-packages/youtrack/youtrackImporter.py", line 76, in _import_issues
    [self._to_yt_issue(issue, project_id) for issue in issues])
  File "/usr/lib/python2.7/site-packages/youtrack/youtrackImporter.py", line 167, in _to_yt_issue
    result.comments = [self._to_yt_comment(comment) for comment in self._get_comments(issue)]
  File "/home/gabriel/projects/gitlab/youtrack-python-scripts/youtrackutils/csv2youtrack.py", line 289, in _to_yt_comment
    result.created = self._import_config.to_unix_date(comment[1])
  File "/home/gabriel/projects/gitlab/youtrack-python-scripts/youtrackutils/csv2youtrack.py", line 463, in to_unix_date
    date, csvClient.DATE_FORMAT_STRING)
  File "/usr/lib/python2.7/_strptime.py", line 335, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: 2019-05-24T09:25:07+02:00

Any idea on that?

P.S: Right, i had to update line line 260 of your code, as the youtrackutils.csvClient.FIELD_NAMES map doesn't seem to work. So i set the csv header to the real values used by the csv2youtrack script.

@yavin5
Copy link
Author

yavin5 commented Jun 4, 2019 via email

@Grummfy
Copy link

Grummfy commented Nov 26, 2020

really bad to see that nobody review it and merge it ;(

@john-jerome
Copy link

Hey, I tried the script today and it worked fine when exporting issues from GitLab.
However, during the second part of importing them to YouTrack I'm getting the following error:

Traceback (most recent call last):
  File "/Users/ivanyeromenko/Documents/GitLab/remetrik-data/gitlab2youtrack.py", line 230, in <module>
    main()
  File "/Users/ivanyeromenko/Documents/GitLab/remetrik-data/gitlab2youtrack.py", line 95, in main
    csv2youtrack.csv2youtrack(params)
  File "/Users/ivanyeromenko/Documents/GitLab/remetrik-data/csv2youtrack.py", line 235, in csv2youtrack
    importer.import_csv()
  File "/Users/ivanyeromenko/Documents/GitLab/remetrik-data/csv2youtrack.py", line 265, in import_csv
    self.do_import(projects, new_projects_owner_login)
  File "/Users/ivanyeromenko/Library/Python/2.7/lib/python/site-packages/youtrack/youtrackImporter.py", line 25, in do_import
    self._create_custom_fields(project_ids)
  File "/Users/ivanyeromenko/Library/Python/2.7/lib/python/site-packages/youtrack/youtrackImporter.py", line 48, in _create_custom_fields
    self._create_field(yt_field[NAME], yt_field[TYPE], yt_field.get(POLICY), yt_field[AUTO_ATTACHED])
  File "/Users/ivanyeromenko/Library/Python/2.7/lib/python/site-packages/youtrack/youtrackImporter.py", line 42, in _create_field
    create_custom_field(self._target, field_type, field_name, auto_attached, bundle_policy=attach_bundle_policy)
  File "/Users/ivanyeromenko/Library/Python/2.7/lib/python/site-packages/youtrack/importHelper.py", line 50, in create_custom_field
    field = _get_custom_field(connection, cf_name)
  File "/Users/ivanyeromenko/Library/Python/2.7/lib/python/site-packages/youtrack/importHelper.py", line 22, in _get_custom_field
    existing_fields = [item for item in connection.getCustomFields() if utf8encode(item.name).lower() ==
  File "/Users/ivanyeromenko/Library/Python/2.7/lib/python/site-packages/youtrack/connection.py", line 855, in getCustomFields
    xml = minidom.parseString(content)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0

Any idea where this might be coming from?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants