[M] Rename /merging to /tools
This commit is contained in:
parent
97cbdecb5e
commit
47c32f07d7
6 changed files with 1 additions and 0 deletions
80
tools/accept_upstream.py
Normal file
80
tools/accept_upstream.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import shlex
|
||||
from subprocess import check_output
|
||||
|
||||
import pyperclip
|
||||
import requests
|
||||
from github import Github
|
||||
|
||||
upstream = 'dylanaraps/neofetch'
|
||||
my_fork = 'hykilpikonna/hyfetch'
|
||||
my_base = 'master'
|
||||
# gh_token = os.environ['GH_TOKEN']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Helper for accepting upstream pull requests')
|
||||
parser.add_argument('pull', type=int, help='Pull request number')
|
||||
args = parser.parse_args()
|
||||
pr = args.pull
|
||||
|
||||
print(f'Accepting pull request {pr}...')
|
||||
|
||||
# Fetch original pr's information
|
||||
info = requests.get(f'https://api.github.com/repos/{upstream}/pulls/{pr}').json()
|
||||
# print(info)
|
||||
head = info['head']['repo']['full_name']
|
||||
head_br = info['head']['ref']
|
||||
head_lbl = info['head']['label']
|
||||
user = info['user']['login']
|
||||
print()
|
||||
print('Original Pull Request Info:')
|
||||
print('> State:', info['state'])
|
||||
print('> Title:', info['title'])
|
||||
print('> User:', user)
|
||||
print('> Created:', info['created_at'])
|
||||
print('> Head:', head, head_br, head_lbl)
|
||||
|
||||
# Fetch commit information
|
||||
commits = requests.get(f'https://api.github.com/repos/{upstream}/pulls/{pr}/commits').json()
|
||||
author = commits[0]['commit']['author']
|
||||
|
||||
# Fetch head branch
|
||||
print()
|
||||
print('Fetching head branch...')
|
||||
os.system(f'git fetch https://github.com/{head} {head_br}')
|
||||
|
||||
# Merge head branch
|
||||
print()
|
||||
print('Merging fetch_head...')
|
||||
title = info["title"].replace('"', '\\"')
|
||||
os.system(f'git merge FETCH_HEAD --no-ff --no-edit '
|
||||
f'-m "[PR] {upstream}#{pr} from {user} - {title}" '
|
||||
f'-m "Upstream PR: https://github.com/{upstream}/pull/{pr} \n'
|
||||
f'Thanks to @{user}\n\n'
|
||||
f'Co-authored-by: {author["name"]} <{author["email"]}>"')
|
||||
|
||||
# Push
|
||||
print()
|
||||
print('Pushing...')
|
||||
os.system('git push')
|
||||
|
||||
# Get commit SHA
|
||||
sha = check_output(shlex.split('git rev-parse --short HEAD')).decode().strip()
|
||||
|
||||
# Copy comment to clipboard
|
||||
comment = f"""
|
||||
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 maintains an updated version of the original 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()
|
||||
print('Done!')
|
||||
print('Comment response copied to clipboard.')
|
||||
39
tools/colors_test.py
Normal file
39
tools/colors_test.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
from hyfetch.color_scale import test_color_scale
|
||||
from hyfetch.color_util import RGB, printc
|
||||
from hyfetch.neofetch_util import get_command_path, run_neofetch
|
||||
from hyfetch.presets import PRESETS
|
||||
|
||||
|
||||
def print_colors_test(colors: list[RGB]):
|
||||
print(''.join(f'{c.to_ansi_rgb()}#' for c in colors))
|
||||
|
||||
|
||||
def test_preset_length():
|
||||
p = PRESETS.get('transgender')
|
||||
print_colors_test(p.with_length(9))
|
||||
print_colors_test(p.with_length(6))
|
||||
p = PRESETS.get('nonbinary')
|
||||
print_colors_test(p.with_length(7))
|
||||
print_colors_test(p.with_length(6))
|
||||
|
||||
|
||||
def test_command_path():
|
||||
print(get_command_path())
|
||||
|
||||
|
||||
def test_rgb_8bit_conversion():
|
||||
for r in range(0, 255, 16):
|
||||
for g in range(0, 255, 16):
|
||||
print(RGB(r, g, 0).to_ansi_rgb(False), end=' ')
|
||||
printc('&r')
|
||||
print()
|
||||
for r in range(0, 255, 16):
|
||||
for g in range(0, 255, 16):
|
||||
print(RGB(r, g, 0).to_ansi_8bit(False), end=' ')
|
||||
printc('&r')
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_rgb_8bit_conversion()
|
||||
test_color_scale()
|
||||
17
tools/deploy.sh
Normal file
17
tools/deploy.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Stop on error
|
||||
set -e
|
||||
|
||||
# Remove old build
|
||||
rm -rf dist/*
|
||||
rm -rf build/*
|
||||
|
||||
# Build
|
||||
python setup.py sdist bdist_wheel
|
||||
|
||||
# Check built files
|
||||
twine check dist/*
|
||||
|
||||
# Upload
|
||||
twine upload dist/*
|
||||
49
tools/list_unresolved.py
Normal file
49
tools/list_unresolved.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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())
|
||||
print(f'There are {len(resolved)} resolved PRs')
|
||||
|
||||
# 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))
|
||||
29
tools/pull_request_markings.yaml
Normal file
29
tools/pull_request_markings.yaml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# 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
|
||||
# [2104] Make DE Fluent on Windows 11
|
||||
2104: duplicate
|
||||
# [2092] Update neofetch
|
||||
2092: troll
|
||||
# [2081] added a q4os ascii
|
||||
2081: duplicate
|
||||
# [2057] add AmogOS (Duplicate of 1904)
|
||||
2057: duplicate
|
||||
# [2051] Typo in comment for col_offset
|
||||
2051: incorrect
|
||||
# [1936] Added PiluX logo.
|
||||
1936: deleted
|
||||
# [1927] improve/add model name for arm linux cpus
|
||||
1927: duplicate
|
||||
# [1850] neofetch: remove duplicate distro ASCII logo
|
||||
1850: duplicate
|
||||
# [1827] Improve manjaro logo
|
||||
1827: deleted
|
||||
21
tools/reformat_readme.py
Normal file
21
tools/reformat_readme.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
This script turns readme shorthand pull request references (i.e. dylanaraps/neofetch#1946) into full
|
||||
GitHub pull request links.
|
||||
"""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
RE_SHORTHAND = re.compile(r"""[a-z0-9]+?/[a-z0-9]+?#[0-9]+""")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
readme = Path('README.md').read_text()
|
||||
|
||||
for shorthand in RE_SHORTHAND.findall(readme):
|
||||
user, pull = shorthand.split('/')
|
||||
repo, pull = pull.split('#')
|
||||
readme = readme.replace(shorthand, f'[{user}#{pull}](https://github.com/{user}/{repo}/pull/{pull})')
|
||||
|
||||
Path('README.md').write_text(readme)
|
||||
Loading…
Add table
Add a link
Reference in a new issue