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

added --ignore-pullrequests option #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 14 additions & 4 deletions gh-issues-import.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def init_config():
config.add_section('target')
config.add_section('format')
config.add_section('settings')

config.add_section('filter')

arg_parser = argparse.ArgumentParser(description="Import issues from one GitHub repository into another.")

config_group = arg_parser.add_mutually_exclusive_group(required=False)
Expand All @@ -54,7 +55,10 @@ def init_config():
arg_parser.add_argument('--ignore-comments', dest='ignore_comments', action='store_true', help="Do not import comments in the issue.")
arg_parser.add_argument('--ignore-milestone', dest='ignore_milestone', action='store_true', help="Do not import the milestone attached to the issue.")
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('--ignore-pullrequests', dest='ignore_pullrequests', action='store_true', help="Do not import issues that are pull requests.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need this on line 112:

config.set('settings', 'import-pullrequests', str(not args.ignore_pullrequests))


arg_parser.add_argument('--filter-labels', dest='filter_labels', help="Comma separated values of labels to use as filters.")

arg_parser.add_argument('--issue-template', help="Specify a template file for use with 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 @@ -242,11 +246,17 @@ def get_issues_by_id(which, issue_ids):
def get_issues_by_state(which, state):
issues = []
page = 1
import_pullrequests = config.getboolean('settings', 'import-pullrequests')
default_labels = ''
labels = config.get('filter', 'labels', fallback=default_labels)
while True:
new_issues = send_request(which, "issues?state=%s&direction=asc&page=%d" % (state, page))
new_issues = send_request(which, "issues?state=%s&direction=asc&page=%d&labels=%s" % (state, page, labels))
if not new_issues:
break
issues.extend(new_issues)
if import_pullrequests:
issues.extend(new_issues)
else:
issues.extend(filter(lambda issue:'pull_request' not in issue ,new_issues))
page += 1
return issues

Expand Down