Skip to content

Commit

Permalink
Add directories to ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
addoshi committed Mar 22, 2016
1 parent 8dadcf2 commit c779c07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/common-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,33 @@ function directories_to_check() {
[ -e ".formatting-directory" ] && locations_to_diff=$( cat .formatting-directory );
}

# If the repo contains a .formatting-directory-ignore file, files in the specified directories will be ignored (one directory per line).
function directories_to_ignore() {
if [ -f ".formatting-directory-ignore" ]; then
files=$(echo "$files" | grep -v -f .formatting-directory-ignore)
fi
}

# Returns a list of Objective-C files to format.
# If .formatting-directory exists, then only directories specified in .formatting-directory will be included (see directories_to_check).
# If .formatting-directory-ignore exists, then directories specified in .formatting-directory-ignore will be excluded (see directories_to_ignore).
# No parameters: return staged ObjC files only
# Optional parameter: a git SHA. Returns a list of all ObjC files which have changed since that SHA
function objc_files_to_format() {
optional_base_sha="$1"
directories_to_check
# optional_base_sha is intentionally unescaped so that it will not appear as empty quotes.
files=$(git diff --cached --name-only $optional_base_sha --diff-filter=ACM -- $locations_to_diff | grep -e '\.m$' -e '\.mm$' -e '\.h$' -e '\.hh$')
directories_to_ignore
echo "$files" | grep -v 'Pods/' | grep -v 'Carthage/' >&1
}

# Returns a list of all Objective-C files in the git repository.
# If .formatting-directory exists, then only directories specified in .formatting-directory will be included (see directories_to_check).
# If .formatting-directory-ignore exists, then directories specified in .formatting-directory-ignore will be excluded (see directories_to_ignore).
function all_valid_objc_files_in_repo() {
directories_to_check
files=$(git ls-tree --name-only --full-tree -r HEAD -- $locations_to_diff | grep -e '\.m$' -e '\.mm$' -e '\.h$' -e '\.hh$')
directories_to_ignore
echo "$files" | grep -v 'Pods/' | grep -v 'Carthage/' >&1
}

0 comments on commit c779c07

Please sign in to comment.