mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-02 01:48:08 +00:00
rename to vouch
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# GitHub handles of users approved to submit PRs.
|
||||
# GitHub handles of vouched contributors.
|
||||
#
|
||||
# See CONTRIBUTING.md for details. The basic idea is that AI in particular
|
||||
# has made it too easy to create plausible-looking but low-quality
|
||||
@@ -6,6 +6,6 @@
|
||||
#
|
||||
# One handle per line (without @). Sorted alphabetically.
|
||||
#
|
||||
# Maintainers can add new contributors by commenting "lgtm" on an
|
||||
# Maintainers can vouch for new contributors by commenting "lgtm" on an
|
||||
# issue by the author.
|
||||
mitchellh
|
||||
@@ -2,38 +2,38 @@
|
||||
|
||||
use github.nu
|
||||
|
||||
# Approved contributor gate commands.
|
||||
# Vouch gate commands.
|
||||
#
|
||||
# Environment variables required:
|
||||
# GITHUB_TOKEN - GitHub API token with repo access. If this isn't
|
||||
# set then we'll attempt to read from `gh` if it exists.
|
||||
def main [] {
|
||||
print "Usage: approved-gate <command>"
|
||||
print "Usage: vouch-gate <command>"
|
||||
print ""
|
||||
print "Commands:"
|
||||
print " pr Check if a PR author is an approved contributor"
|
||||
print " pr Check if a PR author is a vouched contributor"
|
||||
}
|
||||
|
||||
# Check if a PR author is an approved contributor.
|
||||
# Check if a PR author is a vouched contributor.
|
||||
#
|
||||
# Checks if a PR author is a bot, collaborator with write access,
|
||||
# or in the approved contributors list. If not approved, it closes the PR
|
||||
# or in the vouched contributors list. If not vouched, it closes the PR
|
||||
# with a comment explaining the process.
|
||||
#
|
||||
# Outputs a status to stdout: "skipped", "approved", or "closed"
|
||||
# Outputs a status to stdout: "skipped", "vouched", or "closed"
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# # Dry run (default) - see what would happen
|
||||
# ./approved-gate.nu pr 123
|
||||
# ./vouch-gate.nu pr 123
|
||||
#
|
||||
# # Actually close an unapproved PR
|
||||
# ./approved-gate.nu pr 123 --dry-run=false
|
||||
# # Actually close an unvouched PR
|
||||
# ./vouch-gate.nu pr 123 --dry-run=false
|
||||
#
|
||||
def "main pr" [
|
||||
pr_number: int, # GitHub pull request number
|
||||
--repo (-R): string = "ghostty-org/ghostty", # Repository in "owner/repo" format
|
||||
--approved-file: string = ".github/APPROVED_CONTRIBUTORS", # Path to approved contributors file
|
||||
--vouched-file: string = ".github/VOUCHED", # Path to vouched contributors file
|
||||
--dry-run = true, # Print what would happen without making changes
|
||||
] {
|
||||
let owner = ($repo | split row "/" | first)
|
||||
@@ -60,26 +60,26 @@ def "main pr" [
|
||||
|
||||
if ($permission in ["admin", "write"]) {
|
||||
print $"($pr_author) is a collaborator with ($permission) access"
|
||||
print "approved"
|
||||
print "vouched"
|
||||
return
|
||||
}
|
||||
|
||||
# Fetch approved contributors list from default branch
|
||||
let file_data = github api "get" $"/repos/($owner)/($repo_name)/contents/($approved_file)?ref=($default_branch)"
|
||||
# Fetch vouched contributors list from default branch
|
||||
let file_data = github api "get" $"/repos/($owner)/($repo_name)/contents/($vouched_file)?ref=($default_branch)"
|
||||
let content = $file_data.content | decode base64 | decode utf-8
|
||||
let approved_list = $content
|
||||
let vouched_list = $content
|
||||
| lines
|
||||
| each { |line| $line | str trim | str downcase }
|
||||
| where { |line| ($line | is-not-empty) and (not ($line | str starts-with "#")) }
|
||||
|
||||
if ($pr_author | str downcase) in $approved_list {
|
||||
print $"($pr_author) is in the approved contributors list"
|
||||
print "approved"
|
||||
if ($pr_author | str downcase) in $vouched_list {
|
||||
print $"($pr_author) is in the vouched contributors list"
|
||||
print "vouched"
|
||||
return
|
||||
}
|
||||
|
||||
# Not approved - close PR with comment
|
||||
print $"($pr_author) is not approved, closing PR"
|
||||
# Not vouched - close PR with comment
|
||||
print $"($pr_author) is not vouched, closing PR"
|
||||
|
||||
let message = $"Hi @($pr_author), thanks for your interest in contributing!
|
||||
|
||||
@@ -87,7 +87,7 @@ We ask new contributors to open an issue first before submitting a PR. This help
|
||||
|
||||
**Next steps:**
|
||||
1. Open an issue describing what you want to change and why \(keep it concise, write in your human voice, AI slop will be closed\)
|
||||
2. Once a maintainer approves with `lgtm`, you'll be added to the approved contributors list
|
||||
2. Once a maintainer vouches for you with `lgtm`, you'll be added to the vouched contributors list
|
||||
3. Then you can submit your PR
|
||||
|
||||
This PR will be closed automatically. See https://github.com/($owner)/($repo_name)/blob/($default_branch)/CONTRIBUTING.md for more details."
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
use github.nu
|
||||
|
||||
# Approve a contributor by adding them to the APPROVED_CONTRIBUTORS file.
|
||||
# Vouch for a contributor by adding them to the VOUCHED file.
|
||||
#
|
||||
# This script checks if a comment matches "lgtm", verifies the commenter has
|
||||
# write access, and adds the issue author to the approved list if not already
|
||||
# write access, and adds the issue author to the vouched list if not already
|
||||
# present.
|
||||
#
|
||||
# Environment variables required:
|
||||
@@ -17,16 +17,16 @@ use github.nu
|
||||
# Examples:
|
||||
#
|
||||
# # Dry run (default) - see what would happen
|
||||
# ./approve-contributor.nu 123 456789
|
||||
# ./vouch.nu 123 456789
|
||||
#
|
||||
# # Actually approve a contributor
|
||||
# ./approve-contributor.nu 123 456789 --dry-run=false
|
||||
# # Actually vouch for a contributor
|
||||
# ./vouch.nu 123 456789 --dry-run=false
|
||||
#
|
||||
def main [
|
||||
issue_id: int, # GitHub issue number
|
||||
comment_id: int, # GitHub comment ID
|
||||
--repo (-R): string = "ghostty-org/ghostty", # Repository in "owner/repo" format
|
||||
--approved-file: string = ".github/APPROVED_CONTRIBUTORS", # Path to approved contributors file
|
||||
--vouched-file: string = ".github/VOUCHED", # Path to vouched contributors file
|
||||
--dry-run = true, # Print what would happen without making changes
|
||||
] {
|
||||
let owner = ($repo | split row "/" | first)
|
||||
@@ -62,23 +62,23 @@ def main [
|
||||
return
|
||||
}
|
||||
|
||||
# Read approved contributors file
|
||||
let content = open $approved_file
|
||||
let approved_list = $content
|
||||
# Read vouched contributors file
|
||||
let content = open $vouched_file
|
||||
let vouched_list = $content
|
||||
| lines
|
||||
| each { |line| $line | str trim | str downcase }
|
||||
| where { |line| ($line | is-not-empty) and (not ($line | str starts-with "#")) }
|
||||
|
||||
# Check if already approved
|
||||
if ($issue_author | str downcase) in $approved_list {
|
||||
print $"($issue_author) is already approved"
|
||||
# Check if already vouched
|
||||
if ($issue_author | str downcase) in $vouched_list {
|
||||
print $"($issue_author) is already vouched"
|
||||
|
||||
if not $dry_run {
|
||||
github api "post" $"/repos/($owner)/($repo_name)/issues/($issue_id)/comments" {
|
||||
body: $"@($issue_author) is already in the approved contributors list."
|
||||
body: $"@($issue_author) is already in the vouched contributors list."
|
||||
}
|
||||
} else {
|
||||
print "(dry-run) Would post 'already approved' comment"
|
||||
print "(dry-run) Would post 'already vouched' comment"
|
||||
}
|
||||
|
||||
print "already"
|
||||
@@ -86,7 +86,7 @@ def main [
|
||||
}
|
||||
|
||||
if $dry_run {
|
||||
print $"(dry-run) Would add ($issue_author) to ($approved_file)"
|
||||
print $"(dry-run) Would add ($issue_author) to ($vouched_file)"
|
||||
print "added"
|
||||
return
|
||||
}
|
||||
@@ -99,8 +99,8 @@ def main [
|
||||
| append $issue_author
|
||||
| sort -i
|
||||
let new_content = ($comments | append $contributors | str join "\n") + "\n"
|
||||
$new_content | save -f $approved_file
|
||||
$new_content | save -f $vouched_file
|
||||
|
||||
print $"Added ($issue_author) to approved contributors"
|
||||
print $"Added ($issue_author) to vouched contributors"
|
||||
print "added"
|
||||
}
|
||||
4
.github/workflows/pr-gate.yml
vendored
4
.github/workflows/pr-gate.yml
vendored
@@ -25,11 +25,11 @@ jobs:
|
||||
name: ghostty
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Check if contributor is approved
|
||||
- name: Check if contributor is vouched
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
nix develop -c nu .github/scripts/approved-gate.nu pr \
|
||||
nix develop -c nu .github/scripts/vouch-gate.nu pr \
|
||||
-R ${{ github.repository }} \
|
||||
${{ github.event.pull_request.number }} \
|
||||
--dry-run=false
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
name: Approve Contributor
|
||||
name: Vouch
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
approve:
|
||||
vouch:
|
||||
if: ${{ !github.event.issue.pull_request }}
|
||||
runs-on: namespace-profile-ghostty-xsm
|
||||
permissions:
|
||||
@@ -25,12 +25,12 @@ jobs:
|
||||
name: ghostty
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Add contributor to approved list
|
||||
- name: Vouch for contributor
|
||||
id: update
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
status=$(nix develop -c nu .github/scripts/approve-contributor.nu \
|
||||
status=$(nix develop -c nu .github/scripts/vouch.nu \
|
||||
-R ${{ github.repository }} \
|
||||
${{ github.event.issue.number }} \
|
||||
${{ github.event.comment.id }} \
|
||||
@@ -43,8 +43,8 @@ jobs:
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add .github/APPROVED_CONTRIBUTORS
|
||||
git diff --staged --quiet || git commit -m "chore: approve contributor ${{ github.event.issue.user.login }}"
|
||||
git add .github/VOUCHED
|
||||
git diff --staged --quiet || git commit -m "chore: vouch for contributor ${{ github.event.issue.user.login }}"
|
||||
git push
|
||||
|
||||
- name: Comment on issue
|
||||
@@ -53,4 +53,4 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh issue comment ${{ github.event.issue.number }} \
|
||||
--body "@${{ github.event.issue.user.login }} has been added to the approved contributors list. You can now submit PRs. Thanks for contributing!"
|
||||
--body "@${{ github.event.issue.user.login }} has been vouched for and added to the contributors list. You can now submit PRs. Thanks for contributing!"
|
||||
Reference in New Issue
Block a user