{"id":17156344,"url":"https://github.com/jtroo/bb-cli-merge","last_synced_at":"2026-04-29T11:02:07.617Z","repository":{"id":42052408,"uuid":"481165376","full_name":"jtroo/bb-cli-merge","owner":"jtroo","description":"CLI tool for merging Bitbucket pull requests with my desired formatting.","archived":false,"fork":false,"pushed_at":"2022-04-19T22:00:09.000Z","size":27,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T13:46:11.103Z","etag":null,"topics":["bitbucket","git"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtroo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-13T10:09:21.000Z","updated_at":"2022-08-12T23:11:21.000Z","dependencies_parsed_at":"2022-08-12T03:30:59.320Z","dependency_job_id":null,"html_url":"https://github.com/jtroo/bb-cli-merge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jtroo/bb-cli-merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtroo%2Fbb-cli-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtroo%2Fbb-cli-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtroo%2Fbb-cli-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtroo%2Fbb-cli-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtroo","download_url":"https://codeload.github.com/jtroo/bb-cli-merge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtroo%2Fbb-cli-merge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32422532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitbucket","git"],"created_at":"2024-10-14T22:06:12.300Z","updated_at":"2026-04-29T11:02:07.603Z","avatar_url":"https://github.com/jtroo.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitbucket merge CLI tool\n\nThis is an opinionated tool to automate a squash merge for a Bitbucket\npull request with a commit message that differs from the default.\n\nThis tool exists due to my frustration with the default squash merge message\nthat the Bitbucket UI makes upon merging. Especially recently, it no longer\nincludes the entire commit text and truncates it with an ellipsis `...` if the\ncommit text is too long.\n\nI want a commit from a pull request to look like this in my commit history\nafter doing a squash merge:\n\n```\n\u003cPR title\u003e (PR #X)\n\n\u003ccommits text\u003e\n\nApproved by: \u003cApprover 1\u003e\nApproved by: \u003cApprover 2\u003e\n...\n```\n\nSince this isn't built into Bitbucket, I decided to make a CLI tool to do this\nfor me.\n\n# Dependencies\n\n- node\n- bash\n- curl\n- sed\n- awk\n- gpg\n\n# Usage\n\n```sh\n# help\n./bb-merge.sh -h\n\n# print out commit message, do not actually do the merge\n./bb-merge.sh -w \u003cworkspace\u003e -r \u003crepo\u003e [?-c (all|first)] \u003cpr number\u003e\n\n# do the merge\n./bb-merge.sh -w \u003cworkspace\u003e -r \u003crepo\u003e [?-c (all|first)] -a merge \u003cpr number\u003e\n```\n\n# Security\n\nThis code relies on a [Bitbucket app password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/)\nto be able to read from Bitbucket and perform the merge. When first running the\nscript, you will be prompted to input your Bitbucket username and app password.\nThese will be encrypted and stored with `gpg` in `$PWD/.bb-creds.gpg`. Your\ncredentials are not sent anywhere other than to Bitbucket over https. Feel free\nto check the code, there's not that much of it.\n\n# Commit message after merging\n\nThis tool always uses the squash merge strategy. There are two ways that the\ncommit message can be formatted, determined by the `-c | --commit` flag. They\nare mostly similar, with the difference being in the commit body.\n\n## Header\n\nA properly formatted git commit has the following format:\n\n```\nheader\n\nbody\n```\n\nThe header will always be the Pull Request title, as set in the Bitbucket pull\nrequest UI, followed by `(PR #\u003cpr number\u003e)`\n\nExample:\n\n`Fix race condition in db write (PR #99)`\n\n## Body\n\nThe body changes depending on if `all` or `first` is configured for the `-c` flag.\nThe default is `all`.\n\n### Body: `all`\n\nWhen the flag is set to `all`, the commit will have the following appearance:\n\n```\n\u003cheader\u003e\n\n* \u003ccommit 1\u003e\n\n* \u003ccommit 2\u003e\n\n\u003capprovals\u003e\n```\n\nExample:\n\n```\nFix bugs in x and y (PR #101)\n\n* Fix bug in x\n\nBug in x was very confusing. Here is a long description about what the\nroot cause is and how the code change fixes the bug.\n\n* Fix bug in y\n\nBug in y was very confusing. Here is a long description about what the\nroot cause is and how the code change fixes the bug.\n\nApproved by: Me\nApproved by: You\n```\n\n### Body: `first`\n\nWhen the flag is set to `first`, the commit will have the following appearance:\n\n```\n\u003cheader\u003e\n\n\u003ccommit 1 body only\u003e\n\n\u003capprovals\u003e\n```\n\nExample:\n\n```\nFix bug in x (PR #101)\n\nBug in x was very confusing. Here is a long description about what the\nroot cause is and how the code change fixes the bug.\n\nApproved by: Me\nApproved by: You\n```\n\nNote that the header for the commit is stripped out. This is done because the\nassumption is that I put more thought into the PR title in the bitbucket UI as\nopposed to the header of the commit message. The original commit header won't\nbe the actual header after merging, so including the header of the first commit\nmessage is redundant and wasteful.\n\nThis option exists because often I will have a meaningful and useful first\ncommit, but then as part of the review process, add commits after creating the\nPR such as:\n\n```\n* Improve naming of function\n* Improve clarity of doc comment\n```\n\nThese post-creation commits are useful to see during the review process, but\nare useless in the actual git history after merging to main. Using `-c first`,\nthis code will only use the first, useful commit when merging to main.\n\n# My qualms\n\nIf you're curious, below are more of my specific qualms about the default\nBitbucket squash merge message.\n\n- The truncation described above is particularly grievous\n- The default header prefix `Merged in \u003cbranch\u003e` wastes characters and relies\n  on the branch name being useful. Even if your branch name is useful, it's\n  ugly since you can't use whitespace in the branch name.\n- The default header suffix `(pull request #X)` also wastes characters when it\n  could be shortened without losing any meaning. The `PR #X` text correctly\n  hyperlinks in the Bitbucket UI at the time of writing, so there's no reason\n  not to use `PR` instead of `pull request`.\n- Redundant header when the PR is only one commit (see [body: first](#body-first))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtroo%2Fbb-cli-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtroo%2Fbb-cli-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtroo%2Fbb-cli-merge/lists"}