KEMBAR78
Find PRs using `@{push}` by Frederick888 · Pull Request #9208 · cli/cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0179381
Find PRs using @{push}
Frederick888 Jun 14, 2024
7fc35fd
Only find PRs w/ branch.<name>.merge if push.default = upstream/tracking
Frederick888 Jun 14, 2024
4254818
Find push remote using branch.<name>.pushRemote and remote.pushDefault
Frederick888 Jun 14, 2024
2d1e4d6
Add base gh pr view acceptance tests for changes
andyfeller Dec 16, 2024
eb16a75
Expand with gh pr status
andyfeller Dec 16, 2024
8bb2879
Reflect coverage for view and status subcommands
andyfeller Dec 16, 2024
be250b3
Add renamed acceptance tests
andyfeller Dec 16, 2024
0006091
Fix up intra-org fork test setup
andyfeller Dec 18, 2024
48e2681
Merge branch 'trunk' into find-pr-by-rev-parse-push
jtmcg Jan 14, 2025
0184380
Add missing git stubs to tests
jtmcg Jan 15, 2025
4a9fd95
Add comments and a bit of code cleanup
jtmcg Jan 16, 2025
d289ddd
Use PushRemoteURL instead of RemoteURL in prSelectorForCurrentBranch
jtmcg Jan 16, 2025
aef2642
fixup! Add comments and a bit of code cleanup
Frederick888 Jan 16, 2025
41729b0
Refactor finder.Find and replace parseCurrentBranch with parsePRRefs
jtmcg Jan 22, 2025
a72bef9
Error if push revision doesn't match a remote
williammartin Jan 24, 2025
6355ed7
WIP: push default defaults to simple
williammartin Jan 24, 2025
5a8dd35
Add PushDefault method to git client
jtmcg Jan 24, 2025
e4d8ed0
Remove @{push} from branch config
jtmcg Jan 24, 2025
cdead50
Moved remote.pushDefault out of ReadBranchConfig and into finder
jtmcg Jan 24, 2025
d684834
Refactor pr status to use the ParsePRRefs helper on the Finder
jtmcg Jan 24, 2025
4382bdf
Fix pr create tests
jtmcg Jan 24, 2025
62106dc
Cleanup comment
jtmcg Jan 24, 2025
e31bfd0
Cleaned up some naming and comments
jtmcg Jan 28, 2025
e0f624b
Rename PRRefs to PullRequestRefs and PR comment cleanup
jtmcg Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add renamed acceptance tests
  • Loading branch information
andyfeller authored and Frederick888 committed Jan 6, 2025
commit be250b3d332d42fe16bf2b420df2debfc2482a1c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Setup environment variables used for testscript
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
env FORK=${REPO}-fork

# Use gh as a credential helper
exec gh auth setup-git

# Create a repository to act as upstream with a file so it has a default branch
exec gh repo create ${ORG}/${REPO} --add-readme --private

# Defer repo cleanup of upstream
defer gh repo delete --yes ${ORG}/${REPO}
exec gh repo view ${ORG}/${REPO} --json id --jq '.id'
stdout2env REPO_ID

# Create a user fork of repository as opposed to private organization fork
exec gh repo fork ${ORG}/${REPO} --org ${ORG} --fork-name ${FORK}

# Defer repo cleanup of fork
defer gh repo delete --yes ${ORG}/${FORK}
sleep 5
exec gh repo view ${ORG}/${FORK} --json id --jq '.id'
stdout2env FORK_ID

# Clone the repo
exec gh repo clone ${ORG}/${FORK}
cd ${FORK}

# Prepare a branch where changes are pulled from the upstream default branch but pushed to fork
exec git checkout -b feature-branch upstream/main
exec git config branch.feature-branch.pushRemote origin
exec git commit --allow-empty -m 'Empty Commit'
exec git push

# Create the PR spanning upstream and fork repositories, gh pr create does not support headRepositoryId needed for private forks
exec gh api graphql -F repositoryId="${REPO_ID}" -F headRepositoryId="${FORK_ID}" -F query='mutation CreatePullRequest($headRepositoryId: ID!, $repositoryId: ID!) { createPullRequest(input:{ baseRefName: "main", body: "Feature Body", draft: false, headRefName: "feature-branch", headRepositoryId: $headRepositoryId, repositoryId: $repositoryId, title:"Feature Title" }){ pullRequest{ id url } } }'

# View the PR
exec gh pr view
stdout 'Feature Title'

# Check the PR status
env PR_STATUS_BRANCH=#1 Feature Title [${ORG}:feature-branch]
exec gh pr status
stdout $PR_STATUS_BRANCH
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Setup environment variables used for testscript
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}

# Use gh as a credential helper
exec gh auth setup-git

# Create a repository with a file so it has a default branch
exec gh repo create ${ORG}/${REPO} --add-readme --private

# Defer repo cleanup
defer gh repo delete --yes ${ORG}/${REPO}

# Clone the repo
exec gh repo clone ${ORG}/${REPO}
cd ${REPO}

# Configure default push behavior so local and remote branches will be the same
exec git config push.default current

# Prepare a branch where changes are pulled from the default branch instead of remote branch of same name
exec git checkout -b feature-branch
exec git branch --set-upstream-to origin/main
exec git rev-parse --abbrev-ref feature-branch@{upstream}
stdout origin/main

# Create the PR
exec git commit --allow-empty -m 'Empty Commit'
exec git push
exec gh pr create -B main -H feature-branch --title 'Feature Title' --body 'Feature Body'

# View the PR
exec gh pr view
stdout 'Feature Title'

# Check the PR status
env PR_STATUS_BRANCH=#1 Feature Title [feature-branch]
exec gh pr status
stdout $PR_STATUS_BRANCH
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Setup environment variables used for testscript
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
env FORK=${REPO}-fork

# Use gh as a credential helper
exec gh auth setup-git

# Create a repository to act as upstream with a file so it has a default branch
exec gh repo create ${ORG}/${REPO} --add-readme --private

# Defer repo cleanup of upstream
defer gh repo delete --yes ${ORG}/${REPO}
exec gh repo view ${ORG}/${REPO} --json id --jq '.id'
stdout2env REPO_ID

# Create a user fork of repository as opposed to private organization fork
exec gh repo fork ${ORG}/${REPO} --org ${ORG} --fork-name ${FORK}

# Defer repo cleanup of fork
defer gh repo delete --yes ${ORG}/${FORK}
sleep 5
exec gh repo view ${ORG}/${FORK} --json id --jq '.id'
stdout2env FORK_ID

# Clone the repo
exec gh repo clone ${ORG}/${FORK}
cd ${FORK}

# Prepare a branch where changes are pulled from the upstream default branch but pushed to fork
exec git checkout -b feature-branch upstream/main
exec git config remote.pushDefault origin
exec git commit --allow-empty -m 'Empty Commit'
exec git push

# Create the PR spanning upstream and fork repositories, gh pr create does not support headRepositoryId needed for private forks
exec gh api graphql -F repositoryId="${REPO_ID}" -F headRepositoryId="${FORK_ID}" -F query='mutation CreatePullRequest($headRepositoryId: ID!, $repositoryId: ID!) { createPullRequest(input:{ baseRefName: "main", body: "Feature Body", draft: false, headRefName: "feature-branch", headRepositoryId: $headRepositoryId, repositoryId: $repositoryId, title:"Feature Title" }){ pullRequest{ id url } } }'

# View the PR
exec gh pr view
stdout 'Feature Title'

# Check the PR status
env PR_STATUS_BRANCH=#1 Feature Title [${ORG}:feature-branch]
exec gh pr status
stdout $PR_STATUS_BRANCH
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Setup environment variables used for testscript
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}

# Use gh as a credential helper
exec gh auth setup-git

# Create a repository with a file so it has a default branch
exec gh repo create ${ORG}/${REPO} --add-readme --private

# Defer repo cleanup
defer gh repo delete --yes ${ORG}/${REPO}

# Clone the repo
exec gh repo clone ${ORG}/${REPO}
cd ${REPO}

# Configure default push behavior so local and remote branches have to be the same
exec git config push.default simple

# Prepare a branch where changes are pulled from the default branch instead of remote branch of same name
exec git checkout -b feature-branch origin/main

# Create the PR
exec git commit --allow-empty -m 'Empty Commit'
exec git push origin feature-branch
exec gh pr create -H feature-branch --title 'Feature Title' --body 'Feature Body'

# View the PR
exec gh pr view
stdout 'Feature Title'

# Check the PR status
env PR_STATUS_BRANCH=#1 Feature Title [feature-branch]
exec gh pr status
stdout $PR_STATUS_BRANCH