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 ...
14
votes
Accepted
Clone GitHub repository using Python
requests is third-party, so (per the style guide) there should be a blank line in the imports:
import os
import requests
<...
14
votes
Accepted
Taking YouTube links out of a list of GitHub repo READMEs
Here are some concerns/suggestions:
you are reading the file twice - once to get the row count and when reading the links. And, you don't need to initialize the ...
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 ...
13
votes
Accepted
Bash script to simplify Git deployment workflow
Use exit codes directly
Instead of this:
merge $SOURCE_BRANCH 'staging'
status=$?
if [ $status -ne 0 ]
then
echo "ERROR: STEP 1" >&2
exit 1
fi
You ...
12
votes
Accepted
Date of latest GitHub project release
You're actually writing in C but using some C++ features, I'd drop C style (and functions) in favor of their C++ counterparts:
1) Even if you're using a C API you should write C++ classes to hide ...
12
votes
Accepted
Avoiding shell injection when calling Git in Python
Your defense strategy is known as "enumerating badness". As a rule, any strategy based on enumerating badness is doomed to fail. For example, you prohibit rm -rf /...
10
votes
Accepted
Git pre-commit hook to check that changes to certain files only happen on the master branch
Use fewer abbreviations. It's certainly not bad in this case, but small stuff like production instead of prod (unless perhaps it'...
10
votes
Date of latest GitHub project release
Your code can benefit from RAII. For example by creating a small HInternet struct with a destructor to hold a single HINTERNET. ...
9
votes
Accepted
Bash function to parse git status
Porcelain format
As @Vogel612 noted, the --porcelain format is the right one to use for scripting:
The porcelain format is similar to the short format, but is ...
7
votes
Accepted
7
votes
Accepted
Git commit-msg URL shortener
First of all, the `cmd` form of running commands and capturing their output is deprecated. Use the recommended, modern way everywhere: ...
7
votes
Accepted
Walking Git History
CommitVisitor
Using Set<T>.Contains() and returning if it evaluates to truemakes the intent of the code more clear but ...
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 ...
6
votes
Accepted
Python-based Git pre-commit hook to manage multiple users/Git identities
Architecture / general thoughts
Overall looks good. You have lots of mostly useful comments which help
to understand the program, the code is clear if a little verbose, so to
me this was easy to ...
6
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
...
5
votes
Accepted
Bash script to clone all public repos or gists for a specified user, optionally to a directory of choice
It's not a bad attempt, though full of duplicated code and some bad practices.
Checking if a program exists
You do this kind of thing several times:
...
5
votes
Git pre-commit hook to check that changes to certain files only happen on the master branch
Some notes:
zone_files.keys.each and then zone_files[key]. You should iterate the pair: ...
5
votes
Accepted
Bash script to remove unwanted git objects
The shebang: #!/usr/bin/env bash is not needed. env is used to modify the working environment, and since you don't use any of ...
5
votes
Use git to get SHA-1 of repo
Since Janos already gave a nice review on the actual workings of the code, I'll just add some nitpicks:
The python style-guide (PEP-8) defines the maximum line-length to be 79 characters for code (...
5
votes
Accepted
POSIX shell script using a string to store command arguments
First thing, you could turn the check if the checkbashisms tool is installed into a guard clause, shaving off one level of indentation:
...
5
votes
Install, configure, and maintain content for Ubuntu webserver
So, this might not be quite in line with your 100% automation approach, but the best way to provide a shell script access to a git repository is to use ssh keys to allow access to your git repository. ...
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
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
...
4
votes
Python script that does a git diff
if result is False:
raise Exception('diff found between the files')
else:
return 'files are identical'
Why would a difference be considered ...
4
votes
Accepted
Adding SecureString support to Lib2GitSharp
I don't see a problem with how the SecureString objects are handled - seems pretty solid to me, but I've never used those so I'm possibly missing something that ...
4
votes
Ruby script to create git repos
The structure is kinda confusing. empty_name? does a lot more than just tell you if the name's empty, and so does folder_exists?....
4
votes
Accepted
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
git × 133bash × 40
python × 36
beginner × 20
shell × 19
console × 8
javascript × 7
performance × 7
python-3.x × 7
ruby × 7
node.js × 6
object-oriented × 5
linux × 5
java × 4
go × 4
perl × 4
child-process × 4
sh × 4
c# × 3
unit-testing × 3
security × 3
file-system × 3
powershell × 3
installer × 3
make × 3