예제 #1
0
def code_sim_wrap(g, open_issue_url, close_issue_url):
    # use jplag offline, due to moss upload limit
    open_iss_ob = util.get_issue(g, open_issue_url)
    close_iss_ob = util.get_issue(g, close_issue_url)
    code_sim = issue_based_compare(g, open_iss_ob, close_iss_ob, mode='jplag')
    logger.debug(f"Code-sim: {code_sim}")
    return code_sim
    def test_diff(self):
        from persontoken import MY_TOKEN
        g = Github(MY_TOKEN)

        issue = util.get_issue(g, 'https://github.com/owlcs/owlapi/issues/936')
        result = last_commits(g, issue)
        print(result)
def main():
    config = configparser.ConfigParser()
    config.read('jira_search_replace.ini')
    config.read('auth.ini')

    issues = get_issues(config)
    for issue in issues:
        issue = util.get_issue(config['instance'], issue['key'])
        do_search_replace(issue, config)

    print('UPDATE COUNT:', update_count)
예제 #4
0
def _build_issue_dict(g, issue_html_url) -> dict:
    issue_ob = util.get_issue(g, issue_html_url)
    issue_dict = dict()
    issue_dict['html_url'] = issue_ob.html_url
    issue_dict['title'] = issue_ob.title
    if issue_ob.body is None:
        issue_dict['body'] = ""
    else:
        issue_dict['body'] = issue_ob.body
    issue_dict['id'] = issue_ob.id
    issue_dict['number'] = issue_ob.number
    issue_dict['state'] = issue_ob.state
    issue_dict['comments'] = issue_ob.comments  # reply count

    issue_dict['body_len'] = nlp_util.word_count(issue_dict['body'])
    issue_dict['fix'] = contain_fix(g, issue_ob)

    iss_body_tokens = nlp_util.tokenize(issue_dict['body'])
    iss_body_tokens = nlp_util.remove_meanless(iss_body_tokens)
    issue_dict['body_tokens'] = iss_body_tokens

    title_tokens = nlp_util.nlp_process(issue_dict['title'])
    body_list_tokens = nlp_util.nlp_process(issue_dict['body'])

    hot_k = nlp_util.get_hot_keys()
    hit_count_hot_title = search_rank.get_key_sea_count(hot_k, title_tokens, unique=False)
    issue_dict['hit_count_hot_title'] = hit_count_hot_title
    hit_count_hot_body = search_rank.get_key_sea_count(hot_k, body_list_tokens, unique=False)
    issue_dict['hit_count_hot_body'] = hit_count_hot_body

    labels = []
    for _it in issue_ob.labels:
        name = _it.name if _it.name else ""
        description = _it.description if _it.description else ""
        labels.append((name.lower(), description.lower()))
    issue_dict['labels'] = labels

    con_label = nlp_util.get_concern_label()
    labels_c = []
    for _it in issue_dict['labels']:
        name, descrip = _it
        for _c in con_label:
            if _c in name or _c in descrip:
                labels_c.append(_it)
    issue_dict['labels_c'] = labels_c

    return issue_dict
 def test_once(self):
     from persontoken import MY_TOKEN
     g = Github(MY_TOKEN)
     # issob = util.get_issue(g, 'https://github.com/json-path/JsonPath/issues/549')
     # issob = util.get_issue(g, 'https://github.com/deathmarine/Luyten/issues/253')
     issob = util.get_issue(g, 'https://github.com/arthur-star/test/issues/2')
     curr_q = fast_query(issob.title, issob.body)
     try_pair = [
         (True, False, 'body'),  # stacktrace in body
         (False, True, 'title'),  # condition in title
         (False, False, 'title'),  # title in title
         (False, False, 'other')  # title (no field constraint)
     ]
     for _fi, pair in enumerate(try_pair):
         trace, condition, pos = pair
         query_list = form_query(curr_q, None, trace=trace, condition=condition)
         query_chars = " ".join(query_list)
         query_chars = add_pos(query_chars, pos)
         logger.debug(f"query_chars, {query_chars}")
예제 #6
0
def mian():
    from persontoken import MY_TOKEN
    g = Github(MY_TOKEN)
    done_open_urls = util.read_csv('./hist.txt')
    done_open_urls = util.get_col(done_open_urls, 0)

    _f = open("data2.csv", 'a+', encoding='utf-8-sig', newline='')
    _f2 = open("hist.txt", 'a+', encoding='utf-8', newline='')

    try:
        csvwriter = csv.writer(_f, delimiter=',')
        for i, open_url in enumerate(open_urls):
            if open_url in done_open_urls:
                continue
            this_row = [""] * 5
            # open_url = 'https://github.com/json-path/JsonPath/issues/460'
            logger.info("-" * 100)
            logger.info(open_url)
            open_iss_ob = util.get_issue(g, open_url)
            this_row[0] = open_url

            # stacktrace / condition / title
            repo_name = open_iss_ob.repository.full_name
            extra_rm = nlp_util.full_name_token(
                repo_name)  # remove the number and its name
            curr_q = fast_query(open_iss_ob.title, open_iss_ob.body)
            logger.info(f"curr_q, {curr_q}")

            # check sequence stacktrace, condition, title
            try_pair = [
                (True, False, 'body'),  # stacktrace in body
                (False, True, 'title'),  # condition in title
                (False, False, 'title'),  # title in title
                (False, False, 'other')  # title (no field constraint)
            ]
            try_hist = []
            all_fail = True
            for _fi, pair in enumerate(try_pair):
                trace, condition, pos = pair
                query_list = form_query(curr_q,
                                        extra_rm,
                                        trace=trace,
                                        condition=condition)
                query_chars = " ".join(query_list)
                query_chars = add_pos(query_chars, pos)
                logger.debug(f"query_chars, {query_chars}")
                if query_list:
                    close_iss = run_close_query(g,
                                                query_chars,
                                                is_android,
                                                depth=10,
                                                fallback_size=5)
                    try_hist.append(query_chars)
                    this_row[1] = query_chars
                    if close_iss["info"] == 'NORMAL':
                        all_fail = False
                    else:
                        if close_iss["info"] == 'FALLBACK':
                            all_fail = False
                            logger.info(
                                f"[try {_fi}] FALLBACK failed query [Too few results], {query_chars}"
                            )
                        elif close_iss["info"] == 'EMPTY':
                            logger.info(
                                f"[try {_fi}] FALLBACK failed query [Zero results], {query_chars}"
                            )

                    if close_iss["iss"]:
                        # open url, open info online, open info offline, close url, close info (rank property)
                        # 0       , 1               , 2                , 3        , 4

                        rank_list = []
                        for _c in close_iss["iss"]:
                            close_url, close_info = _c
                            if is_android:
                                plugin = android_plugin
                            else:
                                plugin = java_plugin
                            # open url, open info online, open info offline, close url, close info (rank property)
                            # 0       , 1               , 2                , 3        , 4
                            open_off = plugin(g, open_url)
                            close_off = plugin(g, close_url)
                            logger.debug(f"open {open_url}")
                            logger.debug(
                                f"open offline rank, {open_off}=={len(open_off.keys())}"
                            )
                            logger.debug(f"close {close_url}")
                            logger.debug(
                                f"close offline rank, {close_off}=={len(close_off.keys())}"
                            )
                            assert len(open_off.keys()) == len(
                                close_off.keys())
                            all_empty = True
                            join_off = dict()
                            for _k in open_off.keys():
                                join = set(open_off[_k]) & set(close_off[_k])
                                join_off[_k] = list(join)
                                if join:
                                    all_empty = False
                                    close_info.insert(0, f"Off-SIM-{_k}")
                            logger.debug(f"join_off, {join_off}")
                            if all_empty:
                                this_row[2] = "empty offline"
                            else:
                                this_row[2] = json.dumps(join_off)

                            this_row[3] = close_url
                            flag = code_sim_wrap(g, open_url, close_url)
                            if flag:
                                close_info.insert(0, "Code-SIM")
                            this_row[4] = json.dumps(close_info)
                            rank_list.append(deepcopy(this_row))
                        rank_list = rank_issue(rank_list)
                        if rank_list:
                            csvwriter.writerows(rank_list)

                        if close_iss["info"] == 'NORMAL':
                            break

            if all_fail:
                write_list = []
                this_row[4] = 'NONE close issue'
                for col1 in try_hist:
                    this_row[1] = col1
                    write_list.append(deepcopy(this_row))
                csvwriter.writerows(write_list)

            print(open_url, file=_f2)

            _f.flush()
            _f2.flush()
    except Exception as e:
        logger.error(f"{open_url}, skip")
        print(f"{open_url}, skip", file=_f2)
        raise e
    finally:
        _f.close()
        _f2.close()
 def test_last_commits(self):
     from persontoken import MY_TOKEN
     g = Github(MY_TOKEN)
     issue = util.get_issue(g, 'https://github.com/confluentinc/ksql/issues/5062')
     result = last_commits(g, issue)
     print(result)
예제 #8
0
if __name__ == '__main__':
    from persontoken import MY_TOKEN

    g = Github(MY_TOKEN)
    # extract_bugfix("")
    # results = run_open_query(g, "crash", "crash.csv")
    # results = run_open_query(g, "permission Android")
    # print(run_close_query(g, "google action button page", depth=20))

    # https://api.github.com/repos/arquivo/pwa-technologies/issues/931
    # https://api.github.com/repos/wordpress-mobile/WordPress-Android/issues/9685
    # https://api.github.com/repos/tlaplus/tlaplus/issues/477

    ss = util.SS(port=7890)

    # repo = g.get_repo("tlaplus/tlaplus")
    # print(repo.get_topics())
    # print(get_topic("tlaplus/tlaplus"))
    #
    # print(is_android_repo(g, 'nextcloud/android'))
    # print(is_android_repo(g, 'arduino/Arduino'))
    import util

    issue_ob = util.get_issue(g, 'https://github.com/apache/dubbo/issues/6489')
    print(contain_fix(g, issue_ob))
    # a = 'org.springframework.beans.factory.BeanCreationException'
    # a = "a" * 50 + "....." + "ac" * 30
    # a = "-" * 77
    # print(cut_text(a, 54))