From 7d26a8e60cf9434a53a7b2a6b0a7f438cb5869f8 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Sun, 31 Jul 2022 13:18:23 -0400 Subject: [PATCH] [+] Script to list unmerged pr --- .../accept_upstream.py | 2 + merging/list_unresolved.py | 48 +++++++++++++++++++ merging/pull_request_markings.yaml | 13 +++++ 3 files changed, 63 insertions(+) rename accept-upstream.py => merging/accept_upstream.py (94%) create mode 100644 merging/list_unresolved.py create mode 100644 merging/pull_request_markings.yaml diff --git a/accept-upstream.py b/merging/accept_upstream.py similarity index 94% rename from accept-upstream.py rename to merging/accept_upstream.py index 10355d81..b3103bab 100644 --- a/accept-upstream.py +++ b/merging/accept_upstream.py @@ -71,6 +71,8 @@ Thank you for your contribution! This PR is [merged into hyfetch](https://github.com/hykilpikonna/hyfetch/commit/{sha}) since this repo (dylanaraps/neofetch) seems no longer maintained. [HyFetch](https://github.com/hykilpikonna/hyfetch) is a fork of neofetch with LGBTQ pride flags, but the repo also serves as an updated version of neofetch, addressing many pull requests that are not merged in the original repo. + +Read the ["Running Updated Original Neofetch" section](https://github.com/hykilpikonna/hyfetch#running-updated-original-neofetch) for more info! """ pyperclip.copy(comment.strip()) print() diff --git a/merging/list_unresolved.py b/merging/list_unresolved.py new file mode 100644 index 00000000..80a28dfb --- /dev/null +++ b/merging/list_unresolved.py @@ -0,0 +1,48 @@ +import shlex +from pathlib import Path +from subprocess import check_output + +from github import Github +from github.PullRequest import PullRequest +import ruamel.yaml as yaml + + +def obtain_resolved(): + """ + Obtain a list of resolved issues. + """ + prefix = 'dylanaraps/neofetch#' + commits = check_output(shlex.split('git log --pretty=format:"%s"')).decode().strip().split('\n') + commits = [(c, c.find(prefix)) for c in commits] + commits = [(c, i+len(prefix)) for c, i in commits if i != -1] + return sorted([int(c[i:c.find(' ', i)]) for c, i in commits]) + + +if __name__ == '__main__': + # Obtain a list of resolved issues + resolved = set(obtain_resolved()) + + # Read the ignore-list + with open(Path(__file__).parent / "pull_request_markings.yaml") as stream: + ignore_list = yaml.safe_load(stream)['IgnoreList'] + + # Obtain a list of open issues + g = Github(per_page=100) + repo = g.get_repo('dylanaraps/neofetch') + pager = repo.get_pulls(state='open') + + # Filter only unresolved issues + unresolved: list[PullRequest] = [] + for i in range(10000000): + pulls: list[PullRequest] = pager.get_page(i) + if len(pulls) == 0: + break + + unresolved += [p for p in pulls if p.number not in resolved and p.number not in ignore_list and not p.draft] + if len(unresolved) > 50: + break + + unresolved.sort(key=lambda p: p.number) + + # Print unresolved issues + print('\n'.join(f'[{p.number}] {p.title} {p.html_url}' for p in unresolved)) diff --git a/merging/pull_request_markings.yaml b/merging/pull_request_markings.yaml new file mode 100644 index 00000000..cd1a4406 --- /dev/null +++ b/merging/pull_request_markings.yaml @@ -0,0 +1,13 @@ +# Pull request that I don't plan on merging, or already merged pull request that the script didn't +# detect. +IgnoreList: + # [2154] Added Support for Uwuntu + 2154: merged + # [2156] Update neofetch (for macOS 13) + 2156: duplicate + # [2152] created much cleaner void ascii art + 2152: merged + # [2150] Add macOS 13 to version name list + 2150: merged + # [2092] Update neofetch + 2092: troll