This project started to make yourself write better commit messages but later got extended to make your git journey much easier.
% bc help
Usage:
BetterCommit (bc) is a small utility which will help you make an habit of writing better commit messages.
Usage: bc <subcommands>
Available commands:
add Adds all the changes to staging area
commit Adds and commits all the changes
branch Creates a new branch
pr Creates a new pull request
open Open relevant repo in browser
Example usage:
$ bc open
Opens relevant git repository in browser
https://github.com/pgaijin66/bc/blob/main/assets/bc-open.mp4
% bc commit
Is this commit related to any projects tickets / Components / features (eg: JIRA-124, button, vpc): bc
Enter which git operation did you performed (eg: add, update, del): update
INFO: Files modified
M src/bc
What did you update: updated script to show modified files to help user add more context to the commit
[main be3e6a8] update(bc): updated script to show modified files to help user add more context to the commit
1 file changed, 2 insertions(+), 2 deletions(-)
bc does not allow to push in main branch.
% bc push
ERROR: Not recommended to push to main branch. Please create a new branch using "bc branch"
bc prompts you if try to push and still have some pending changes to be committed.
% bc push
There are still changes to be committed. Are you sure you want to push? [y/N]
bc allows you to create queryable git branches.
% bc branch
Is this commit related to any projects tickets / Components / features (eg: JIRA-124, button, vpc): certs
What kind of work is this (eg: bugfix, feat, demo, test): feat
What work will be done in this branch: Add support for application to run TLS natively
Switched to a new branch 'feat/certs/Add-support-for-application-to-run-TLS-natively'
At the end you are left with this clean sexy looking git friendly branch
feat/certs/Add-support-for-application-to-run-TLS-natively
which you can query ( suppose if i want to see how many people are working on features ) now i could just do
git branch --list "feat/*"
feat/cert/create-a-new-self-signed-certificate
* feat/certs/Add-support-for-application-to-run-TLS-natively
bc allows you to create pr from terminal. bc looks for env var called GH_TOKEN
when creating a PR, so please generate one before you go about creating a new PR. Steps to generate PAT shown below.
% bc pr
Title of the Pull Request: Add new command to create PR
Is this PR associated with any ticket (eg: JIRA-124]): bc-124
Explain work done in this PR (When finished hit ctrl-d on a new line to proceed):
Add new command to create PR from terminal
Updated Makefile to substitute variable based on OS Type
PR type (eg: SHOW, SHIP. ASK): SHIP
What kind of change is this (eg: Bufix, Feature, Breaking Change, Doc update): Feature
Source branch name: feat/bc/Add-pr-from-terminal-command
Destination branch name: main
When you are done, bc
will check if the branch has been pushed to origin or not, and if its pushed, then it will create a new PR.
NOTE: To use this command, you would need to generate GH PAT ( Personal Access Token)
- Go to 'Profile > Settting'
- Click on 'Developer settings'
- Click 'Personal acces tokens' > 'Fine grained tokens'
- Click 'Generate new token'
- Given 'Token name', 'Expiration'
- In Repository access, select whether you want to use bc to create PR in all respsitory. If that is the case then select 'All repositories'. If not then, select individual repositories
- Once 'Repository access' is selected, add permission via 'Permissions > Repository permissions'
- Provide access to create PR by clicking drop down on 'Pull requests > Access: Read and Write'
- Click 'Generate token'
- Token will be shown only once hence save it someplace safe.
- Add token export to your rc file.
If you are on mac or using zsh then do this
echo 'export GH_TOKEN="github_pat_1....REDACTED"' >> ~/.zshrc
If you are on linux or using bash then do this
echo 'export GH_TOKEN="github_pat_1....REDACTED"' >> ~/.bash_rc
-
Clone repository
git clone https://github.com/pgaijin66/bc.git
-
Navigate to the cloned directory.
-
Run
task install-osx
to install
Note: I am working on setting up installation via homebrew, however for now you can install it using task install-osx. You might have to install go-task for thos
% make help
help List targets & descriptions
install Installs binary to standard library PATH4
tag-n-release Tags and pushes
uninstall Uninstalls application
- Prettify and format commit message.
- Stop committting and pushing changes to main branch.
- Create querable branches.
- Make compatible with
bash
as well. Currently works onzsh
- Create GH PR from terminal.
- Allow use to interactively choose which files to commit.
- interactively cherry pick commits from one branch to another.
- Make reabasing easy
Please create a PR for contribution to this project.
This is a tool i made for myself, as time and again i would get lazy and and skip the most important part while programming ( write good commit messages ). There is no doubt that this work can be done with a simple function alias to ~/.zshrc
or ~/.bashrc
as well but why make it easy when you can add multiple layers of encapsulation. After all that is what automation is right. :P
Commits: https://github.com/pgaijin66/bc/commits/main
Branches: https://github.com/pgaijin66/bc/branches