Skip to content

Commit d415648

Browse files
authored
Merge pull request #50 from unixorn/more-codeclimate-cleanup
More codeclimate cleanup
2 parents 46a5ff5 + a2eb2b7 commit d415648

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# git-extra-commands
22

3+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4+
[![Build Status](https://travis-ci.org/unixorn/git-extra-commands.svg?branch=master)](https://travis-ci.org/unixorn/git-extra-commands)
5+
[![Code Climate](https://codeclimate.com/github/unixorn/git-extra-commands/badges/gpa.svg)](https://codeclimate.com/github/unixorn/git-extra-commands)
6+
[![Issue Count](https://codeclimate.com/github/unixorn/git-extra-commands/badges/issue_count.svg)](https://codeclimate.com/github/unixorn/git-extra-commands)
7+
[![GitHub stars](https://img.shields.io/github/stars/unixorn/bigriver-tools.svg)](https://github.com/unixorn/bigriver-tools/stargazers)
8+
39
A zsh plugin that packages some extra git helper scripts I've found. I only wrote a few of these scripts, and the ones I didn't each have whatever licensing is included in the file.
410

511
This collection doesn't actually require zsh, but packaging it as a ZSH plugin makes it more convenient for people using a ZSH framework to use this collection.

bin/git-changes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#
33
# https://github.com/cofi/dotfiles/blob/master/bin
44

5-
git log --pretty=format:'%an <%ae>' $1 | sort | uniq -c | sort -nr
5+
exec git log --pretty=format:'%an <%ae>' "$1" | sort | uniq -c | sort -nr

bin/git-clone-subset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ if [[ -e .git/refs/original/ ]] ; then
147147
git "for-each-ref" --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
148148
fi &&
149149
git reflog expire --expire=now --all &&
150-
git gc --prune=now
150+
git gc --prune=now

bin/git-delete-local-merged

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
#
66
# https://plus.google.com/115587336092124934674/posts/dXsagsvLakJ
77

8-
git branch -d `git branch --merged | grep -v '^*' | tr -d '\n'`
8+
# shellcheck disable=SC2046,SC2063
9+
exec git branch -d $(git branch --merged | grep -v '^*' | tr -d '\n')

bin/git-delete-merged-branches

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ if [[ "${currentBranch}" != "${mergedInto}" ]]; then
1515
exit 1
1616
fi
1717

18-
git branch --merged ${mergedInto} | grep -v "\* ${mergedInto}" | xargs -n 1 git branch -d
18+
git branch --merged "${mergedInto}" | grep -v "\* ${mergedInto}" | xargs -n 1 git branch -d

bin/git-move-commits

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set -e
1212

1313
if [ "$1" ]
1414
then
15+
# shellcheck disable=SC2046,SC2143
1516
if [ ! $(echo "$1" | grep -E "^[0-9]+$") ]
1617
then
1718
echo "$1 is not a number."
@@ -27,25 +28,27 @@ else
2728
echo "Usage: git move-commits <num-commits> <correct-branch>";
2829
exit 1;
2930
fi
30-
if [ -z $2 ]
31+
if [ -z "$2" ]
3132
then
3233
echo "Usage: git move-commits <num-commits> <correct-branch>";
3334
exit 1;
3435
else
35-
BRANCH=$2
36+
BRANCH="$2"
3637
fi
3738

38-
CURRENT_BRANCH=`git branch | grep '*' | perl -e '<STDIN> =~ /^..(.+)$/;print $1'`
39+
# shellcheck disable=SC2063
40+
CURRENT_BRANCH=$(git branch | grep '*' | perl -e '<STDIN> =~ /^..(.+)$/;print $1')
3941

4042
# If the branch already exists, we have to merge it with the current branch
41-
if ! [ -z `git branch -a | grep $BRANCH` ]
43+
# shellcheck disable=SC2143,SC2046
44+
if ! [ -z $(git branch -a | grep "$BRANCH") ]
4245
then
4346
echo "$BRANCH already exists. Switching to it and merging $CURRENT_BRANCH"
44-
git checkout $BRANCH
45-
git merge $CURRENT_BRANCH
47+
git checkout "$BRANCH"
48+
git merge "$CURRENT_BRANCH"
4649
else
4750
echo "Creating $BRANCH"
48-
git branch $BRANCH
51+
git branch "$BRANCH"
4952
fi
50-
git reset --hard $CURRENT_BRANCH~$NUM_COMMITS
51-
git checkout $BRANCH
53+
git reset --hard "$CURRENT_BRANCH~$NUM_COMMITS"
54+
git checkout "$BRANCH"

bin/git-rebase-theirs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ inplace=0
2424
ext=".bak"
2525

2626
message() { printf "%s\n" "$1" >&2 ; }
27+
# shellcheck disable=SC2104
2728
skip() { message "skipping ${2:-$file}${1:+: $1}"; continue ; }
2829
argerr() { printf "%s: %s\n" "$myname" "${1:-error}" >&2 ; usage 1 ; }
2930
invalid() { argerr "invalid option: $1" ; }
@@ -102,6 +103,7 @@ for file in "${files[@]}"; do
102103

103104
if ((inplace)); then
104105
outfile=$(mktemp) || skip "could not create temporary file"
106+
# shellcheck disable=SC2064
105107
trap "rm -f -- '$outfile'" EXIT
106108
cp "$file" "$outfile" || skip
107109
exec 3>"$outfile"
@@ -125,4 +127,4 @@ for file in "${files[@]}"; do
125127
trap - EXIT
126128

127129
if ((verbose)); then message "resolved ${file}"; fi
128-
done
130+
done

0 commit comments

Comments
 (0)