After having a good experience with virtualenvwrapper built on top of the venv, I thought maybe it could be benefitial to have similar shortcuts for standard activities with git which could be time saving as opposite to typing many commands.
I've given it a try like the following:
Start session (sync current repository with origin, create a session branch for the to-be merge request):
#!/bin/bash set -ex DATE=$(date +%F) git fetch --all --prune git pull git branch "$USER-$DATE" git checkout "$USER-$DATE"
Close session and integrate results to origin:
#!/bin/bash set -ex DATE=$(date +%F) DEFAULT_BRANCH = "main" git add . --all git commit -m "$1" git push -o merge_request.create -o merge_request.target=$DEFAULT_BRANCH origin "$USER-$DATE" git checkout $DEFAULT_BRANCH git branch -d "$USER-$DATE"
This works.. more or less, but it would be great to sort out some concerns I have got, general and specific.
- In general, maybe there is something I am missing therefore fixing details is waste of time because then I will discover some fundamental blocker, or maybe it's a common problem already solved (maybe in this, or other way)
- Specifically, there is some bash scripting yet to do which I could though sort out in separately, but maybe this is not all, therefore I try to review these details myself first.
So the issues with the code are, from what I see:
- It's random whether the default branch is called "main" either "master". So the script needs to detect/decide that somehow.
- The merge request branch name could be derived from repository name
- Not sure what could be a proper error handling to enable for defined states
- Is it matter of taste, or reasonable decision to put these scripts as separate files under
~/bin, either integrate as functions to something bigger, and call through command line parameters? Then I will have possibly to look on Bash tabbing as well.
Thanks for reading and looking forward to your feedback!