fetch_jira_bugs/find_bug_fixes.py
def find_bug_fixes(issue_path, gitlog_path, gitlog_pattern, save_path=None):
    """ Identify bugfixes in Jenkins repository given a list of issues """
    if save_path is None:
        save_path = ''

    i = 0 # Used to display progress
    no_matches = []
    matches_per_issue = {}
    total_matches = 0

    issue_list = build_issue_list(issue_path)
    with open(gitlog_path) as f:
        gitlog = json.loads(f.read())

    for key in issue_list:
        nbr = key.split('-')[1]
        matches = []

        for commit in gitlog:
            pattern = gitlog_pattern.format(nbr=nbr)
            if re.search(pattern, commit):
                matches.append(commit)
        total_matches += len(matches)
        matches_per_issue[key] = len(matches)

        if matches:
            selected_commit = commit_selector_heuristic(matches)
            if not selected_commit:
                no_matches.append(key)
            else:
                issue_list[key]['hash'] = \
                    re.search('(?<=^commit )[a-z0-9]+(?=\n)', \
                    selected_commit).group(0)
                issue_list[key]['commitdate'] = \
                    re.search('(?<=\nDate:   )[0-9 -:+]+(?=\n)',\
                    selected_commit).group(0)
        else:
            no_matches.append(key)

        # Progress counter
        i += 1
        if i % 10 == 0:
            print(i, end='\r')

    print('Total issues: ' + str(len(issue_list)))
    print('Issues matched to a bugfix: ' + str(len(issue_list) - len(no_matches)))
    print('Percent of issues matched to a bugfix: ' + \
          str((len(issue_list) - len(no_matches)) / len(issue_list)))
    for key in no_matches:
        issue_list.pop(key)
    
    try:
        os.makedirs(save_path, exist_ok=True)
    except FileNotFoundError:
        pass
    save_fixed = os.path.join(save_path, 'issue_list.json')
    with open(save_fixed, 'w') as f:
        f.write(json.dumps(issue_list))

    return issue_list
 Identify bugfixes in Jenkins repository given a list of issues 
Identify bugfixes in Jenkins repository given a list of issues
Identify bugfixes in Jenkins repository given a list of issues
def find_bug_fixes(issue_path, gitlog_path, gitlog_pattern, save_path=None):
    if save_path is None:
        save_path = ''
    i = 0 
    no_matches = []
    matches_per_issue = {}
    total_matches = 0
    issue_list = build_issue_list(issue_path)
    with open(gitlog_path) as f:
        gitlog = json.loads(f.read())
    for key in issue_list:
        nbr = key.split('-')[1]
        matches = []
        for commit in gitlog:
            pattern = gitlog_pattern.format(nbr=nbr)
            if re.search(pattern, commit):
                matches.append(commit)
        total_matches += len(matches)
        matches_per_issue[key] = len(matches)
        if matches:
            selected_commit = commit_selector_heuristic(matches)
            if not selected_commit:
                no_matches.append(key)
            else:
                issue_list[key]['hash'] = \
                    re.search('(?<=^commit )[a-z0-9]+(?=\n)', \
                    selected_commit).group(0)
                issue_list[key]['commitdate'] = \
                    re.search('(?<=\nDate:   )[0-9 -:+]+(?=\n)',\
                    selected_commit).group(0)
        else:
            no_matches.append(key)
        i += 1
        if i % 10 == 0:
            print(i, end='\r')
    print('Total issues: ' + str(len(issue_list)))
    print('Issues matched to a bugfix: ' + str(len(issue_list) - len(no_matches)))
    print('Percent of issues matched to a bugfix: ' + \
          str((len(issue_list) - len(no_matches)) / len(issue_list)))
    for key in no_matches:
        issue_list.pop(key)
    try:
        os.makedirs(save_path, exist_ok=True)
    except FileNotFoundError:
        pass
    save_fixed = os.path.join(save_path, 'issue_list.json')
    with open(save_fixed, 'w') as f:
        f.write(json.dumps(issue_list))
    return issue_list
def find_bug_fixes ( issue_path , gitlog_path , gitlog_pattern , save_path = None ) : if save_path is None : save_path = '' i = 0 no_matches = [ ] matches_per_issue = { } total_matches = 0 issue_list = build_issue_list ( issue_path ) with open ( gitlog_path ) as f : gitlog = json . loads ( f . read ( ) ) for key in issue_list : nbr = key . split ( '-' ) [ 1 ] matches = [ ] for commit in gitlog : pattern = gitlog_pattern . format ( nbr = nbr ) if re . search ( pattern , commit ) : matches . append ( commit ) total_matches += len ( matches ) matches_per_issue [ key ] = len ( matches ) if matches : selected_commit = commit_selector_heuristic ( matches ) if not selected_commit : no_matches . append ( key ) else : issue_list [ key ] [ 'hash' ] = re . search ( '(?<=^commit )[a-z0-9]+(?=\n)' , selected_commit ) . group ( 0 ) issue_list [ key ] [ 'commitdate' ] = re . search ( '(?<=\nDate:   )[0-9 -:+]+(?=\n)' , selected_commit ) . group ( 0 ) else : no_matches . append ( key ) i += 1 if i % 10 == 0 : print ( i , end = '\r' ) print ( 'Total issues: ' + str ( len ( issue_list ) ) ) print ( 'Issues matched to a bugfix: ' + str ( len ( issue_list ) - len ( no_matches ) ) ) print ( 'Percent of issues matched to a bugfix: ' + str ( ( len ( issue_list ) - len ( no_matches ) ) / len ( issue_list ) ) ) for key in no_matches : issue_list . pop ( key ) try : os . makedirs ( save_path , exist_ok = True ) except FileNotFoundError : pass save_fixed = os . path . join ( save_path , 'issue_list.json' ) with open ( save_fixed , 'w' ) as f : f . write ( json . dumps ( issue_list ) ) return issue_list
Identify bugfixes in Jenkins repository given a list of issues
Identify bugfixes in Jenkins repository given a list of issues
""" Identify bugfixes in Jenkins repository given a list of issues """ # Used to display progress # Progress counter
issue_path
gitlog_path
gitlog_pattern
save_path