16
votes
Accepted
Git delete all merged in local branches
Improve your file handling:
Don't use a hard coded file name for temporary files.
Don't spew temporary files into the current directory.
Make sure you clean up temporary files even on error.
The first ...
14
votes
Git delete all merged in local branches
DRY - don't repeat yourself
"Don't repeat yourself" is a popular programming principle. You could apply it here by not repeating your filename over and over.
...
14
votes
Git Push Bash script
Rather than make it interactive
read -p "Continue? " yn
I would make this more like other command line tools. You have default values and allow ...
7
votes
Git delete all merged in local branches
I am assuming you are starting nano so that you may remove possible occurrences of master branch (or some other static branch) ...
7
votes
Accepted
A Python script that generates git commits for the last year
Python is actually well-known for having a unified style-guide. It is called PEP8. It has both general advice as well as specific advice (naming and such). flake8 ...
7
votes
Git Push Bash script
If you're going to keep your script interactive, I'd reorder these lines:
git add .
read -r -p "Commit name/number/identifier: " NUM
to
...
7
votes
Git Push Bash script
Do you really expect the user to type in REMOTE and BRANCH, copying the output of the previous commands? What if the user makes a typo? Why bothering the user at all?
Instead of
...
5
votes
Accepted
Measure size of repository as a function of time
This is good, useful, powerful. Let's make it better!
There's no need for os here, so remove it. os.curdir can just be ...
5
votes
Accepted
Tracking 1400+ client codes, multi-threading nightmare
First, I'm pretty sure that it's impossible for
os.chdir(path)
to meaningfully apply different working directories per thread; and even if it were possible it ...
5
votes
Git Push Bash script
Add a default in your case, take into account that the user could press any key besides y an n.
– schrodingerscatcuriosity, CC BY-SA 4.0, 2022-06-24 22:18:07
Community wiki
4
votes
Accepted
Git pie - Perl oneliner for Git
As written, $new will contain the return value of s///, which is 1 (true) or the empty string (false). This will (almost) never ...
4
votes
Git Insert Delete Graph
Overview
It is great that you:
Used strict and warnings
Leveraged other people's code by using the CPAN modules
Used comments ...
4
votes
Accepted
automating to push changes to github for multiple repos using python
Review
Stick to the PEP8 style guide
Functions and variables should be snake_case
Constants like gitUrl should be ...
4
votes
Accepted
Bash/zsh function that cd to the root of git tree
Great
100% pass on shellcheck which means you're doing great with quoting everything that could be potentially problematic.
scoping variables
using [[ conditional ...
4
votes
Accepted
How to reduce the build time of Docker image layer in GitHub Actions?
COPY ZscalerRootCertificate-2048-SHA256.crt /usr/local/share/ca-certificates/ZscalerRootCertificate-2048-SHA256.crt
The command here runs, presumably, on a file.
...
3
votes
Accepted
Counting times a file was committed to Git
I was going to say that this shouldn't be done in C#, but then after some thought last night, I came up with a really dirty idea.
You're basically trying to get the count of things that happened with ...
3
votes
Accepted
GitHub repo tree generator
@Reinderien's answer makes a very good point about docstrings and using those to describe your code: it would be much easier to understand if I knew what the various components are generally intended ...
3
votes
GitHub repo tree generator
I see nothing wrong with the code itself, but you're in dire need of docstrings. Arcane functional one-liners like the one in intersperse are impenetrable unless ...
3
votes
Git delete all merged in local branches
I've actually written a script to do the same thing myself. My tips:
Advice
I wouldn't use git branch, its output is only meant to be human readable (in git ...
3
votes
Daily Add/Del Git Log Analysis
I would apply the following improvements:
use collections.defaultdict to count down the number of added and deleted lines separately. This would help to improve the ...
3
votes
Bash: change git remote from SSH to HTTPS within a given dir
Extracting remote urls
Parsing the config file is error-prone. A much better way to extract the information about remotes is using Git commands. This will simplify your script a great deal.
...
3
votes
Safely pruning merged topic branches locally
Previous exit code
This will only ever print 0 exit code:
if [[ ${1} ]]; then echo "The previous command exited with ${?}"; fi
Because the last exit code at the ...
3
votes
Accepted
Safely pruning merged topic branches locally
The final line has no effect:
trap error SIGHUP SIGINT SIGTERM
As the program is about to exit, we're exceedingly unlikely to receive any of those signals ...
3
votes
bash wrapper around 'git commit' to automatically bump (Python) package CalVer and create matching CalVer tag on new commit
First of all I'd like to recommend shellcheck (online, GitHub) as a very useful tool to detect errors (even small misspellings of variables) and possible misbehaviours, etc.. With this you would have ...
3
votes
Accepted
Syncing GitHub repositories local, remote and forks
There's no need to reinstate the initial value of IFS because there's nowhere for the new value to propogate. When your script exits, the new value just ceases to ...
3
votes
Accepted
Display git commit statistics in bash
Some suggestions:
shellcheck should give you a few suggestions. I won't mention things I expect it to find.
Uppercase names are by convention only used for exported ...
3
votes
Accepted
Pre-commit hook to prevent large file commits
Although described as a Bash script, this appears to be a portable shell script that can be run by any POSIX-conformant shell. That's a good thing, as it means we can use a much smaller, leaner shell ...
3
votes
How to manipulate directories using Python
Enumerate
counter = 1
for repo in git_repo_tags:
# ...
print('--Removing the .git folder ' + str(counter) + '/8')
counter += 1
should be using ...
3
votes
Fast git change sets with git wrapping scripts
Addressing your main concerns
In general, maybe there is something I am missing therefore fixing details is waste of time [...]
Actually I'm wondering if there's something that I am missing about ...
3
votes
How to reduce the build time of Docker image layer in GitHub Actions?
We have two goals for a speedy build of a docker image:
small image
small diffs
I notice you're not yet using
layers.
You want to.
You start out with LTS Jammy Jellyfish as the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
git × 129bash × 39
python × 37
shell × 20
beginner × 19
console × 8
javascript × 7
performance × 7
ruby × 7
node.js × 6
python-3.x × 5
sh × 5
java × 4
object-oriented × 4
go × 4
linux × 4
perl × 4
child-process × 4
c# × 3
security × 3
file-system × 3
installer × 3
make × 3
c++ × 2
parsing × 2