Skip to content

sign the commit created by gh deliver #27

Description

@lakruzz
git commit-tree -h
usage: git commit-tree <tree> [(-p <parent>)...]
   or: git commit-tree [(-p <parent>)...] [-S[<keyid>]] [(-m <message>)...]
                       [(-F <file>)...] <tree>

    -p <parent>           id of a parent commit object
    -m <message>          commit message
    -F <file>             read commit log message from file
    -S, --gpg-sign[=<key-id>]
                          GPG sign commit

gh deliver --verbose

# Check if the user has access to right version of gh CLI
$ gh --version
gh version 2.83.2 (2025-12-10)
https://github.com/cli/cli/releases/tag/v2.83.2

# Fetch all branches and tags from all remotes
$ git fetch --tags --all -f 


# Get the name of the current branch
$ git rev-parse --abbrev-ref HEAD

# Get the SHA1 of the current branch
$ git rev-parse HEAD

# Get the status of the working directory
$ git status --porcelain

# Get the name of the remote
$ git remote
4ce06b7ed822c14168758d505f93e2750021827f
origin
109-Takt


# Get the name of the default branch from GitHub
$ gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'

# Get the current repository name in the format 'owner/repo'
$ gh repo view --json nameWithOwner -q '.nameWithOwner'
lakruzz/lakruzz.com
main

# Get the merge base of the current branch and the default branch
$ git merge-base 109-Takt origin/main

# Get the SHA1 of the default branch
$ git rev-parse origin/main

# Get the SHA1 of the remote branch
$ git rev-parse origin/109-Takt

# Get the GitHub username of the authenticated user
$ gh api /user --jq '.login'
778fb77756ad6e19e22f3ae27ae1876037d17d63
4ce06b7ed822c14168758d505f93e2750021827f
778fb77756ad6e19e22f3ae27ae1876037d17d63
lakruzz

# Get the title of the issue from GitHub
$ gh issue view 109 --json title --jq '.title'

# Get the commit log of the current branch since the merge base
$ git log --format='%h: '%B 778fb77756ad6e19e22f3ae27ae1876037d17d63..109-Takt
4ce06b7: done - #109

eb4e076: Ready for final review - #109

c43959d: ready for review - #109

d1f059f: ready for review - #109
Takt

# Collapse the branch, since the merge base into a single commit
$ git commit-tree 4ce06b7ed822c14168758d505f93e2750021827f^{tree} -p 778fb77756ad6e19e22f3ae27ae1876037d17d63 -m "Takt - resolves #109

4ce06b7: done - #109

eb4e076: Ready for final review - #109

c43959d: ready for review - #109

d1f059f: ready for review - #109"
efdc83a718d198c932426197df3e72d19fee639b

# Verify that the new squeezed commit tree is identical to the one on the issue branch
$ git diff-tree --no-commit-id --name-only -r 4ce06b7ed822c14168758d505f93e2750021827f efdc83a718d198c932426197df3e72d19fee639b


# Get the properties from the issue
$ gh issue view 109 --json url,title,number,labels,assignees,closed,comments
{"assignees":[{"id":"MDQ6VXNlcjE1NTQ5Mg==","login":"lakruzz","name":"Lars Kruse","databaseId":0}],"closed":false,"comments":[],"labels":[{"id":"LA_kwDOLf44YM8AAAACE7Q8TA","name":"ad hoc","description":"Ad hoc work, not part of a strict planned upstream kanban cycle","color":"00aa00"}],"number":109,"title":"Takt","url":"https://github.com/lakruzz/lakruzz.com/issues/109"}

# Get the project id
$ gh project view 13 --owner lakruzz --format json --jq '.id'
# NOTE! Returning cached value from previous run
PVT_kwHOAAJfZM4A9Y0Q

# Add the issue to the project
$ gh project item-add 13 --owner lakruzz --url https://github.com/lakruzz/lakruzz.com/issues/109 --format json --jq '.id'
# NOTE! Returning cached value from previous run
PVTI_lAHOAAJfZM4A9Y0QzgjYCuQ

# Get the field description in json format
$ gh project field-list 13 --owner lakruzz --format json --jq '.fields[] | select(.name == "Status")'
# NOTE! Returning cached value from previous run
{"id":"PVTSSF_lAHOAAJfZM4A9Y0QzgxGtek","name":"Status","options":[{"id":"f75ad846","name":"Todo"},{"id":"47fc9ee4","name":"In Progress"},{"id":"ba2e627b","name":"Delivery Initiated"},{"id":"98236657","name":"Done"}],"type":"ProjectV2SingleSelectField"}

# Update the field with the option
$ gh project item-edit --project-id PVT_kwHOAAJfZM4A9Y0Q --field-id PVTSSF_lAHOAAJfZM4A9Y0QzgxGtek --id PVTI_lAHOAAJfZM4A9Y0QzgjYCuQ --single-select-option-id ba2e627b


# Push the squeezed sha to the remote as a ready branch
$ git push --force origin efdc83a718d198c932426197df3e72d19fee639b:refs/heads/ready/109-Takt
remote: 
remote: Create a pull request for 'ready/109-Takt' on GitHub by visiting:        
remote:      https://github.com/lakruzz/lakruzz.com/pull/new/ready/109-Takt        
remote: 
To https://github.com/lakruzz/lakruzz.com.git
 * [new branch]      efdc83a718d198c932426197df3e72d19fee639b -> ready/109-Takt
👍 SUCCESS: Branch '109-Takt' has been squeezed into one commit; 'efdc83a' and pushed to origin as 'ready/109-Takt'
💡 Run: gh workflow view ready

# Get the name of the default branch from GitHub
$ gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'

# Get the current repository name in the format 'owner/repo'
$ gh repo view --json nameWithOwner -q '.nameWithOwner'
lakruzz/lakruzz.com
main
Press Ctrl+C to stop polling - will exit when all checks are done.
Polling commit efdc83a7 for statuses every 4 seconds...

# Getting commit status for SHA efdc83a7
$ gh api -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' /repos/lakruzz/lakruzz.com/commits/efdc83a718d198c932426197df3e72d19fee639b/status

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions