Skip to content

Commit 46a5ff5

Browse files
authored
Merge pull request #49 from unixorn/configure-code-climate-tests
Add .codeclimate.yml
2 parents e2559ea + c6fe56d commit 46a5ff5

14 files changed

+115
-37
lines changed

.codeclimate.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
engines:
3+
pep8:
4+
enabled: true
5+
duplication:
6+
enabled: true
7+
config:
8+
languages:
9+
- "python"
10+
fixme:
11+
enabled: true
12+
exclude_paths:
13+
- config/engines.yml
14+
pep8:
15+
enabled: true
16+
checks:
17+
E111:
18+
enabled: false
19+
E501:
20+
enabled: false
21+
markdownlint:
22+
enabled: true
23+
checks:
24+
MD004:
25+
enabled: false
26+
MD007:
27+
enabled: false
28+
MD013:
29+
enabled: false
30+
MD026:
31+
enabled: false
32+
MD029:
33+
enabled: false
34+
MD033:
35+
enabled: false
36+
MD034:
37+
enabled: false
38+
MD038:
39+
enabled: false
40+
shellcheck:
41+
enabled: true
42+
ratings:
43+
paths:
44+
- "bin/**/*"
45+
- "**.py"
46+
- "**.md"
47+
exclude_paths:
48+
- .bundle/
49+
- benchmarks/**/*
50+
- build/
51+
- dist/
52+
- include/**/*
53+
- lib/**/*
54+
- License.md
55+
- spec/**/*

Contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## Contributing
1+
# Contributing
22

33
**git-extra-commands** is a collection of helper scripts for git and links to git-related articles.
44

5-
# Contribution Guidelines
5+
## Contribution Guidelines
66

77
- **To add a helper script:** Submit a pull request. Please use `#!/usr/bin/env interpreter` instead of a direct path to the interpreter, this makes it easier for people to use more recent versions when the ones packaged with their OS (macOS and CentOS, I'm looking at you) are stale.
88
- **To remove a script:** All of the scripts here were either taken from blog posts or had an Open Source license. That said, if you wrote something included here and want it removed, either open an issue to discuss the removal or submit a pull request.

PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<!--- Provide a general summary of your changes in the Title above -->
22

3-
## Description
3+
# Description
4+
45
<!--- Describe your changes in detail -->
56

6-
## Screenshots (if appropriate):
7+
# Type of changes
78

8-
## Type of changes
99
<!--- What types of changes does your submission introduce? Put an `x` in all the boxes that apply: -->
10+
1011
- [ ] A helper script
1112
- [ ] A link to an external resource like a blog post
1213

13-
## Checklist:
14+
# Checklist:
15+
1416
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
1517
<!--- If you're unsure about any of these, don't hesitate to ask. I'm happy to help! -->
18+
1619
- [ ] All new and existing tests pass.
17-
- [ ] Any scripts added use `#!/usr/bin/env interpreter` instead of potentially platform-specific direct paths (`#!/bin/sh` is an ok exception)
20+
- [ ] Any scripts added use `#!/usr/bin/env interpreter` instead of potentially platform-specific direct paths (`#!/bin/sh` is an ok exception)\
21+
- [ ] Scripts are marked executable
1822
- [ ] I have confirmed that the link(s) in my PR are valid.
1923
- [ ] I have read the **CONTRIBUTING** document.

bin/git-change-author

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Author: Michael Demmer https://github.com/demmer
33
# License: MIT
44
# Original source: https://github.com/jut-io/git-scripts/blob/master/bin/git-change-author
55

6-
prog=`basename $0`
6+
prog=$(basename "$0")
77

88
force=
99
if [ "$1" == "-f" ] ; then
@@ -28,6 +28,7 @@ export old_email
2828
export new_author
2929
export new_email
3030

31+
# shellcheck disable=SC2016,SC2048,SC2086
3132
git filter-branch $force --env-filter '
3233
an="$GIT_AUTHOR_NAME"
3334
am="$GIT_AUTHOR_EMAIL"

bin/git-copy-branch-name

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# Copy the current branch name to the clipboard.
44

55
branch=$(git rev-parse --abbrev-ref HEAD)
6-
echo $branch
6+
echo "$branch"
77

88
if [[ "$(uname -s)" = "Darwin" ]]; then
9-
echo $branch | tr -d '\n' | tr -d ' ' | pbcopy
9+
echo "$branch" | tr -d '\n' | tr -d ' ' | pbcopy
1010
fi

bin/git-cut-branch

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set -e
1010

1111
# bail out with message to stderr and exit status 1
1212
die() {
13+
# shellcheck disable=SC2086
1314
echo "$(basename $0):" "$@" 1>&2
1415
exit 1
1516
}
@@ -20,6 +21,7 @@ shortsha() {
2021
}
2122

2223
# show usage
24+
# shellcheck disable=SC2166
2325
[ -z "$1" -o "$1" = "--help" ] && {
2426
grep '^#/' "$0" |cut -c4-
2527
exit 2
@@ -44,6 +46,7 @@ remote=$(git config --get "branch.$current.remote" || true)
4446
merge=$(git config --get "branch.$current.merge" | sed 's@refs/heads/@@')
4547

4648
# build up a sane <remote>/<branch> name
49+
# shellcheck disable=SC2166
4750
if [ -n "$remote" -a -n "$merge" ]
4851
then tracking="$remote/$merge"
4952
elif [ -n "$merge" ]
@@ -63,5 +66,7 @@ git reset -q --hard "$tracking"
6366
git checkout -q "$branch"
6467
git branch --set-upstream "$branch" "$tracking"
6568
git reset -q --hard "$sha"
69+
# shellcheck disable=SC2086,SC2046
6670
echo "[$(shortsha "$sha")...$(shortsha $(git rev-parse $tracking))] $current"
71+
# shellcheck disable=SC2046
6772
echo "[0000000...$(shortsha $(git rev-parse HEAD))] $branch"

bin/git-divergence

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ set -e
66

77
(
88
function branch() {
9+
# shellcheck disable=SC2063
910
git branch 2>/dev/null | grep -e '^*' | tr -d '\* '
1011
}
1112

1213
function ensure_valid_ref() {
1314
ref=$1
1415
(
1516
set +e
16-
git show-ref $ref > /dev/null
17+
git show-ref "$ref" > /dev/null
1718
if [[ $? == 1 ]]; then
1819
echo "$0: bad ref: $ref"
1920
exit 1
@@ -22,9 +23,10 @@ set -e
2223
}
2324

2425
function show_rev() {
25-
rev=$1
26-
git log -1 $rev --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
26+
rev="$1"
27+
git log -1 "$rev" --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
2728
echo
29+
# shellcheck disable=SC2086
2830
git diff $rev^..$rev | diffstat
2931
echo
3032
}
@@ -33,29 +35,31 @@ set -e
3335
LOCAL=$1
3436
REMOTE=$2
3537
elif [[ $# == 1 ]]; then
36-
LOCAL=`branch`
38+
LOCAL=$(branch)
3739
REMOTE=$1
3840
else
39-
LOCAL=`branch`
41+
LOCAL=$(branch)
4042
REMOTE=origin/$LOCAL
4143
fi
4244

43-
ensure_valid_ref $LOCAL
44-
ensure_valid_ref $REMOTE
45+
ensure_valid_ref "$LOCAL"
46+
ensure_valid_ref "$REMOTE"
4547

4648
echo "changes from local ${LOCAL} to remote ${REMOTE}:"
4749
echo
4850

4951
echo incoming:
5052
echo
51-
for rev in `git rev-list $LOCAL..$REMOTE`; do
52-
show_rev $rev
53+
# shellcheck disable=SC2086
54+
for rev in $(git rev-list $LOCAL..$REMOTE); do
55+
show_rev "$rev"
5356
done
5457

5558
echo
5659
echo outgoing:
5760
echo
58-
for rev in `git rev-list $REMOTE..$LOCAL`; do
59-
show_rev $rev
61+
# shellcheck disable=SC2086
62+
for rev in $(git rev-list $REMOTE..$LOCAL); do
63+
show_rev "$rev"
6064
done
6165
) | less -r

bin/git-github-open

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
## Open current file in vim on line 20:
1515
## :!github-open % 20
1616

17+
# shellcheck disable=SC2002,SC2086
1718
set -e
1819

1920
FILE="$1"
@@ -34,13 +35,14 @@ die() {
3435
# figure out relative path to the file from the root
3536
# of the work tree
3637
path="$(basename $FILE)"
37-
cd $(dirname $FILE)
38+
cd "$(dirname $FILE)"
3839
while test ! -d .git ;
3940
do
4041
test "$(pwd)" = / && {
4142
echo "error: git repository not found" 1>&2
4243
exit 1
4344
}
45+
# shellcheck disable=SC2046
4446
path="$(basename $(pwd))/$path"
4547
cd ..
4648
done
@@ -81,4 +83,4 @@ url="http://github.com/$repo/blob/$branch/$path"
8183
# throw the line number on there if specified
8284
test -n "$LINE" && url="$url#L$LINE"
8385

84-
open "$url"
86+
open "$url"

bin/git-incoming-commits

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ username="$1"
1212
if [ -n "$2" ] ; then
1313
repo="$2"
1414
else
15+
# shellcheck disable=SC2046
1516
repo=$(basename $(pwd))
1617
fi
1718

1819
command="git remote add $username git://github.com/$username/$repo.git"
19-
echo $command
20+
echo "$command"
2021
$command
2122

2223
command="git fetch $username"
23-
echo $command
24+
echo "$command"
2425
$command

bin/git-move-commits

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
# moves the last n commits to correct-branch
77
# if correct-branch doesn't exist, it creates it
88
# if correct-branch does exist, it merges the commits
9+
# shellcheck disable=SC2046,SC2143,SC2006,SC2086,SC2063
10+
911
set -e
1012

11-
if [ $1 ]
13+
if [ "$1" ]
1214
then
1315
if [ ! $(echo "$1" | grep -E "^[0-9]+$") ]
1416
then
@@ -17,7 +19,7 @@ then
1719
exit 1;
1820
else
1921
# The count is 0 based, so to move the last 1 commit, we need HEAD~0
20-
NUM_COMMITS=$1
22+
NUM_COMMITS="$1"
2123
((NUM_COMMITS--))
2224
echo "num commits $NUM_COMMITS"
2325
fi

0 commit comments

Comments
 (0)