From 53df7858624d74dcf739b6f47115456566780d74 Mon Sep 17 00:00:00 2001 From: Faisal Nugroho Date: Thu, 28 May 2026 12:32:49 +0800 Subject: [PATCH 1/2] chore: add root-level .gitattributes for cross-platform consistency Adds .gitattributes to ensure consistent line endings across platforms. - Sets LF as default line ending for all text files - Marks binary files correctly (images, fonts) - Marks lock files as generated (no diff) Closes #2657 --- .gitattributes | 49 +++++++++++++++++++++++++++++++++++++ auth_test.py | 23 ++++++++++++++++++ push_and_pr.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ push_pr.py | 57 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 .gitattributes create mode 100644 auth_test.py create mode 100644 push_and_pr.py create mode 100644 push_pr.py diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..5fa4dc9e3f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,49 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# JavaScript +*.js text eol=lf +*.jsx text eol=lf +*.mjs text eol=lf +*.cjs text eol=lf + +# TypeScript +*.ts text eol=lf +*.tsx text eol=lf +*.mts text eol=lf +*.cts text eol=lf + +# Web +*.html text eol=lf +*.css text eol=lf +*.scss text eol=lf + +# Data +*.json text eol=lf +*.yaml text eol=lf +*.yml text eol=lf + +# Config +*.md text eol=lf +*.mdx text eol=lf +*.toml text eol=lf + +# Shell scripts +*.sh text eol=lf +*.bash text eol=lf + +# Binary files +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.svg text eol=lf +*.woff binary +*.woff2 binary +*.ttf binary +*.eot binary + +# Lock files (should not be normalized) +pnpm-lock.yaml -diff linguist-generated=true +package-lock.json -diff linguist-generated=true diff --git a/auth_test.py b/auth_test.py new file mode 100644 index 0000000000..e5f6742806 --- /dev/null +++ b/auth_test.py @@ -0,0 +1,23 @@ +import os, json, urllib.request + +token = None +with open(os.path.expanduser("~/.hermes/.env")) as f: + for line in f: + line = line.strip() + if line.startswith("GITHUB_TOKEN=") and not line.startswith("#"): + token = line.split("=", 1)[1].strip().strip('"').strip("'") + break + +print("Token length:", len(token) if token else 0) + +# Test the token +req = urllib.request.Request( + "https://api.github.com/user", + headers={"Authorization": "token " + token} +) +try: + resp = urllib.request.urlopen(req) + user = json.loads(resp.read()) + print("Authenticated as:", user["login"]) +except urllib.error.HTTPError as e: + print("Auth error:", e.code, e.read().decode()[:200]) diff --git a/push_and_pr.py b/push_and_pr.py new file mode 100644 index 0000000000..c5e28369aa --- /dev/null +++ b/push_and_pr.py @@ -0,0 +1,66 @@ +import subprocess, os, json, urllib.request + +token = None +env_path = os.path.expanduser("~/.hermes/.env") +with open(env_path) as f: + for line in f: + line = line.strip() + if line.startswith("GITHUB_TOKEN=") and not line.startswith("#"): + token = line.split("=", 1)[1].strip() + token = token.strip('"').strip("'") + break + +if not token: + print("ERROR: No GITHUB_TOKEN found") + exit(1) + +branch = os.environ.get("BRANCH", "feat/add-validation-scripts") +title = os.environ.get("TITLE", "feat: add root-level validation workflow scripts") +body = os.environ.get("BODY", "") + +cred_file = os.path.expanduser("~/.git-credentials") +with open(cred_file, "w") as f: + f.write("https://faisalnugroho:" + token + "@github.com\n") + +subprocess.run(["git", "config", "credential.helper", "store"], check=True) + +env2 = os.environ.copy() +env2["GIT_TERMINAL_PROMPT"] = "0" + +result = subprocess.run( + ["git", "push", "origin", branch], + capture_output=True, text=True, env=env2 +) +print("Push:", result.stdout, result.stderr) + +subprocess.run(["git", "remote", "set-url", "origin", + "https://github.com/faisalnugroho/onchainkit.git"], check=True) + +if result.returncode != 0: + print("Push failed") + exit(1) + +pr_data = json.dumps({ + "title": title, + "body": body, + "head": "faisalnugroho:" + branch, + "base": "main" +}).encode() + +req = urllib.request.Request( + "https://api.github.com/repos/coinbase/onchainkit/pulls", + data=pr_data, + headers={ + "Authorization": "token " + token, + "Accept": "application/vnd.github+json", + "Content-Type": "application/json" + }, + method="POST" +) + +try: + resp = urllib.request.urlopen(req) + result = json.loads(resp.read()) + print("PR #" + str(result["number"]) + ": " + result["html_url"]) +except urllib.error.HTTPError as e: + print("Error:", e.read().decode()[:500]) diff --git a/push_pr.py b/push_pr.py new file mode 100644 index 0000000000..f47b10df42 --- /dev/null +++ b/push_pr.py @@ -0,0 +1,57 @@ +import subprocess, os, json, urllib.request + +# Read token +token = None +with open(os.path.expanduser("~/.hermes/.env")) as f: + for line in f: + if line.startswith("GITHUB_TOKEN=") and not line.startswith("#"): + token = line.split("=", 1)[1].strip() + break + +if not token: + print("ERROR: No GITHUB_TOKEN found") + exit(1) + +branch = os.environ.get("BRANCH", "feat/add-validation-scripts") +title = os.environ.get("TITLE", "feat: add root-level validation workflow scripts") +body = os.environ.get("BODY", "") +closes = os.environ.get("CLOSES", "") + +# Push +subprocess.run(["git", "remote", "set-url", "origin", + f"https://faisalnugroho:***@github.com/faisalnugroho/onchainkit.git"], + check=True) + +result = subprocess.run(["git", "push", "origin", branch], + capture_output=True, text=True) +print("Push:", result.stdout or result.stderr) + +subprocess.run(["git", "remote", "set-url", "origin", + "https://github.com/faisalnugroho/onchainkit.git"], check=True) + +# Create PR +pr_data = json.dumps({ + "title": title, + "body": body, + "head": f"faisalnugroho:{branch}", + "base": "main" +}).encode() + +req = urllib.request.Request( + "https://api.github.com/repos/coinbase/onchainkit/pulls", + data=pr_data, + headers={ + "Authorization": f"token {token}", + "Accept": "application/vnd.github+json", + "Content-Type": "application/json" + }, + method="POST" +) + +try: + resp = urllib.request.urlopen(req) + result = json.loads(resp.read()) + print(f"PR #{result['number']}: {result['html_url']}") +except Exception as e: + err_body = e.read().decode() if hasattr(e, 'read') else str(e) + print(f"Error: {err_body[:500]}") From ae4faaba670bba5ecd2dd17d477071fccf75e28f Mon Sep 17 00:00:00 2001 From: Faisal Nugroho Date: Thu, 28 May 2026 12:32:56 +0800 Subject: [PATCH 2/2] chore: remove temporary helper scripts --- auth_test.py | 23 ------------------ push_and_pr.py | 66 -------------------------------------------------- push_pr.py | 57 ------------------------------------------- 3 files changed, 146 deletions(-) delete mode 100644 auth_test.py delete mode 100644 push_and_pr.py delete mode 100644 push_pr.py diff --git a/auth_test.py b/auth_test.py deleted file mode 100644 index e5f6742806..0000000000 --- a/auth_test.py +++ /dev/null @@ -1,23 +0,0 @@ -import os, json, urllib.request - -token = None -with open(os.path.expanduser("~/.hermes/.env")) as f: - for line in f: - line = line.strip() - if line.startswith("GITHUB_TOKEN=") and not line.startswith("#"): - token = line.split("=", 1)[1].strip().strip('"').strip("'") - break - -print("Token length:", len(token) if token else 0) - -# Test the token -req = urllib.request.Request( - "https://api.github.com/user", - headers={"Authorization": "token " + token} -) -try: - resp = urllib.request.urlopen(req) - user = json.loads(resp.read()) - print("Authenticated as:", user["login"]) -except urllib.error.HTTPError as e: - print("Auth error:", e.code, e.read().decode()[:200]) diff --git a/push_and_pr.py b/push_and_pr.py deleted file mode 100644 index c5e28369aa..0000000000 --- a/push_and_pr.py +++ /dev/null @@ -1,66 +0,0 @@ -import subprocess, os, json, urllib.request - -token = None -env_path = os.path.expanduser("~/.hermes/.env") -with open(env_path) as f: - for line in f: - line = line.strip() - if line.startswith("GITHUB_TOKEN=") and not line.startswith("#"): - token = line.split("=", 1)[1].strip() - token = token.strip('"').strip("'") - break - -if not token: - print("ERROR: No GITHUB_TOKEN found") - exit(1) - -branch = os.environ.get("BRANCH", "feat/add-validation-scripts") -title = os.environ.get("TITLE", "feat: add root-level validation workflow scripts") -body = os.environ.get("BODY", "") - -cred_file = os.path.expanduser("~/.git-credentials") -with open(cred_file, "w") as f: - f.write("https://faisalnugroho:" + token + "@github.com\n") - -subprocess.run(["git", "config", "credential.helper", "store"], check=True) - -env2 = os.environ.copy() -env2["GIT_TERMINAL_PROMPT"] = "0" - -result = subprocess.run( - ["git", "push", "origin", branch], - capture_output=True, text=True, env=env2 -) -print("Push:", result.stdout, result.stderr) - -subprocess.run(["git", "remote", "set-url", "origin", - "https://github.com/faisalnugroho/onchainkit.git"], check=True) - -if result.returncode != 0: - print("Push failed") - exit(1) - -pr_data = json.dumps({ - "title": title, - "body": body, - "head": "faisalnugroho:" + branch, - "base": "main" -}).encode() - -req = urllib.request.Request( - "https://api.github.com/repos/coinbase/onchainkit/pulls", - data=pr_data, - headers={ - "Authorization": "token " + token, - "Accept": "application/vnd.github+json", - "Content-Type": "application/json" - }, - method="POST" -) - -try: - resp = urllib.request.urlopen(req) - result = json.loads(resp.read()) - print("PR #" + str(result["number"]) + ": " + result["html_url"]) -except urllib.error.HTTPError as e: - print("Error:", e.read().decode()[:500]) diff --git a/push_pr.py b/push_pr.py deleted file mode 100644 index f47b10df42..0000000000 --- a/push_pr.py +++ /dev/null @@ -1,57 +0,0 @@ -import subprocess, os, json, urllib.request - -# Read token -token = None -with open(os.path.expanduser("~/.hermes/.env")) as f: - for line in f: - if line.startswith("GITHUB_TOKEN=") and not line.startswith("#"): - token = line.split("=", 1)[1].strip() - break - -if not token: - print("ERROR: No GITHUB_TOKEN found") - exit(1) - -branch = os.environ.get("BRANCH", "feat/add-validation-scripts") -title = os.environ.get("TITLE", "feat: add root-level validation workflow scripts") -body = os.environ.get("BODY", "") -closes = os.environ.get("CLOSES", "") - -# Push -subprocess.run(["git", "remote", "set-url", "origin", - f"https://faisalnugroho:***@github.com/faisalnugroho/onchainkit.git"], - check=True) - -result = subprocess.run(["git", "push", "origin", branch], - capture_output=True, text=True) -print("Push:", result.stdout or result.stderr) - -subprocess.run(["git", "remote", "set-url", "origin", - "https://github.com/faisalnugroho/onchainkit.git"], check=True) - -# Create PR -pr_data = json.dumps({ - "title": title, - "body": body, - "head": f"faisalnugroho:{branch}", - "base": "main" -}).encode() - -req = urllib.request.Request( - "https://api.github.com/repos/coinbase/onchainkit/pulls", - data=pr_data, - headers={ - "Authorization": f"token {token}", - "Accept": "application/vnd.github+json", - "Content-Type": "application/json" - }, - method="POST" -) - -try: - resp = urllib.request.urlopen(req) - result = json.loads(resp.read()) - print(f"PR #{result['number']}: {result['html_url']}") -except Exception as e: - err_body = e.read().decode() if hasattr(e, 'read') else str(e) - print(f"Error: {err_body[:500]}")