Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-source features #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config-enterprise.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ password = plaintext_pass\/\/ord
# If unsure, just using '%c' will default to the locale’s appropriate date and time representation.
#date = %A %b %d, %Y at %H:%M GMT # Sample: Friday Sep 13, 2013 at 22:58 GMT

# If importing issues from multiple sources you can specify a title prefix and label to apply to all issues
#issue_title_prefix = [old-repo-name]
#issue_label = old-repo-name

3 changes: 3 additions & 0 deletions config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ repository = OctoDog/Hello-World
# If unsure, just using '%c' will default to the locale’s appropriate date and time representation.
#date = %A %b %d, %Y at %H:%M GMT # Sample: Friday Sep 13, 2013 at 22:58 GMT

# If importing issues from multiple sources you can specify a title prefix and label to apply to all issues
#issue_title_prefix = [old-repo-name]
#issue_label = old-repo-name
19 changes: 19 additions & 0 deletions gh-issues-import.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def init_config():
arg_parser.add_argument('--ignore-labels', dest='ignore_labels', action='store_true', help="Do not import labels attached to the issue.")

arg_parser.add_argument('--issue-template', help="Specify a template file for use with issues.")
arg_parser.add_argument('--issue-title-prefix', help="Specify a prefix for issue titles.")
arg_parser.add_argument('--issue-label', help="Specify a label to add to all new issues.")
arg_parser.add_argument('--comment-template', help="Specify a template file for use with comments.")
arg_parser.add_argument('--pull-request-template', help="Specify a template file for use with pull requests.")

Expand Down Expand Up @@ -99,6 +101,8 @@ def load_config_file(config_file_name):
if args.target: config.set('target', 'repository', args.target)

if args.issue_template: config.set('format', 'issue_template', args.issue_template)
if args.issue_title_prefix: config.set('format', 'issue_title_prefix', args.issue_title_prefix)
if args.issue_label: config.set('format', 'issue_label', args.issue_label)
if args.comment_template: config.set('format', 'comment_template', args.comment_template)
if args.pull_request_template: config.set('format', 'pull_request_template', args.pull_request_template)

Expand Down Expand Up @@ -324,6 +328,21 @@ def get_label_by_name(name):
new_issue = {}
new_issue['title'] = issue['title']

#Add custom title prefix?
if config.has_option('format', 'issue_title_prefix'):
new_issue['title'] = config.get('format', 'issue_title_prefix') + " " + issue['title']

#Add new label
if config.has_option('format', 'issue_label'):
new_lable = {
"name": config.get('format', 'issue_label'),
"color": '000000' #Default to black, easy to find and can be changed globally later
}
if 'labels' in issue:
issue['labels'].append(new_lable)
else:
issue['labels'] = [new_lable]

# Temporary fix for marking closed issues
if issue['closed_at']:
new_issue['title'] = "[CLOSED] " + new_issue['title']
Expand Down