<commit_before>#!/usr/bin/python
###############################################################################
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
#
# Script to add back fields that are not automatically exported by JIRA export.
# Also performs mappings between resolutions and versions for history reasons.
# This uses the REST API for both the old and new servers to figure out the
# version mappings and to get the latest values for "component", "resolution",
# and "fixVersions".
#
###############################################################################
import json
import requests
import sys
import time
from collections import defaultdict
from remap_users import get_user_mappings

# Custom fields. These vary by project. If this doesn't apply to you, just
# leave the CUSTOM_FIELD_NAMES list blank.
CUSTOM_FIELD_NAMES = [ "Target Version/s" ]

# This "Resolution" map is manually constructed by looking at the output from
# the REST API calls from the source and destination JIRAs. In this case:
#
# https://issues.cloudera.org/rest/api/2/resolution
# https://issues.apache.org/jira/rest/api/2/resolution
#
# If you are importing from/to other JIRA servers then you will have to come up
# with your own mappings. This can't be fully automated because the names
# aren't guaranteed to match (custom Resolution values are common).
# On the bright side, "Resolution" is "global" for a given JIRA server -- it's
# not project-specific.
resolution_map = {
    "1" : "1", # Fixed
    "2" : "2", # Won't fix
    "3" : "3", # Duplicate
    "4" : "4", # Incomplete
    "5" : "5", # Works for me / Cannot reproduce
    "6" : "6", # Not A Bug / Invalid
    "10003" : "7", # Feedback received / Later
    "10001" : "8", # Won't do / Not a problem
    "10104" : "9", # Information provided / Unresolved
    "10008" : "10", # Delivered / Implemented
    "10000" : "11", # Done
    "z1" : "10000", # Auto Closed
    "z2" : "10001", # Pending Closed
    "z3" : "10002", # REMIND
    "z4" : "10003", # Resolved
    "10002" : "5", # Cannot reproduce
    "10005" : "8", # Not delivered
    "10006" : "1", # Staged
    "10007" : "2", # Workaround
    "10100" : "1", # Configuration change
    "10101" : "1", # Deployed
    "10102" : "1", # Patch applied
    "10103" : "1", # Patch created
    "10104" : "4", # Unresolved

    # Alternate world of resolutions from jira.cloudera.com (due to a prior JIRA migration).
    "7" : "1", # Patch created
    "8" : "1", # Patch applied
    "9" : "1", # Configuration change
    "10" : "6", # Not a bug
    "11" : "7", # Feedback received
    "12" : "9", # Information provided
    "13" : "1", # Delivered
    "14" : "8", # Not Delivered
    "15" : "9", # Unresolved<commit_msg>Fix typo in mapping for Information Provided (issues.cloudera.org)<commit_after>#!/usr/bin/python
###############################################################################
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
#
# Script to add back fields that are not automatically exported by JIRA export.
# Also performs mappings between resolutions and versions for history reasons.
# This uses the REST API for both the old and new servers to figure out the
# version mappings and to get the latest values for "component", "resolution",
# and "fixVersions".
#
###############################################################################
import json
import requests
import sys
import time
from collections import defaultdict
from remap_users import get_user_mappings

# Custom fields. These vary by project. If this doesn't apply to you, just
# leave the CUSTOM_FIELD_NAMES list blank.
CUSTOM_FIELD_NAMES = [ "Target Version/s" ]

# This "Resolution" map is manually constructed by looking at the output from
# the REST API calls from the source and destination JIRAs. In this case:
#
# https://issues.cloudera.org/rest/api/2/resolution
# https://issues.apache.org/jira/rest/api/2/resolution
#
# If you are importing from/to other JIRA servers then you will have to come up
# with your own mappings. This can't be fully automated because the names
# aren't guaranteed to match (custom Resolution values are common).
# On the bright side, "Resolution" is "global" for a given JIRA server -- it's
# not project-specific.
resolution_map = {
    "1" : "1", # Fixed
    "2" : "2", # Won't fix
    "3" : "3", # Duplicate
    "4" : "4", # Incomplete
    "5" : "5", # Works for me / Cannot reproduce
    "6" : "6", # Not A Bug / Invalid
    "10003" : "7", # Feedback received / Later
    "10001" : "8", # Won't do / Not a problem
    "10004" : "9", # Information provided / Unresolved
    "10008" : "10", # Delivered / Implemented
    "10000" : "11", # Done
    "z1" : "10000", # Auto Closed
    "z2" : "10001", # Pending Closed
    "z3" : "10002", # REMIND
    "z4" : "10003", # Resolved
    "10002" : "5", # Cannot reproduce
    "10005" : "8", # Not delivered
    "10006" : "1", # Staged
    "10007" : "2", # Workaround
    "10100" : "1", # Configuration change
    "10101" : "1", # Deployed
    "10102" : "1", # Patch applied
    "10103" : "1", # Patch created
    "10104" : "4", # Unresolved

    # Alternate world of resolutions from jira.cloudera.com (due to a prior JIRA migration).
    "7" : "1", # Patch created
    "8" : "1", # Patch applied
    "9" : "1", # Configuration change
    "10" : "6", # Not a bug
    "11" : "7", # Feedback received
    "12" : "9", # Information provided
    "13" : "1", # Delivered
    "14" : "8", # Not Delivered
    "15" : "9", # Unresolved
{'fraction_non_alphanumeric': 0.18351103769334734, 'fraction_numerical': 0.04565250037543175, 'mean_word_length': 3.71671388101983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7288845', 'n_tokens_mistral': 2161, 'n_tokens_neox': 1947, 'n_words': 790}