Skip to content

Commit

Permalink
Ignore Generated folder from the swift fmt pre commit hook (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
alphatroya authored Oct 13, 2020
1 parent f9b8702 commit 7a3f843
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.7] - 2020-10-13
### Changed
- Исключил Generated папку из списка форматирования pre-commit хуков
- Хуки теперь хранятся в папке hooks проекта

## [1.2.6] - 2020-10-12
### Added
- Добавил кэширование клонированных зависимостей SPM для Bitrise CI
Expand Down
4 changes: 1 addition & 3 deletions {{ cookiecutter.name }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ endif

## hook: Install git pre-commit hook
hook:
curl "https://gist.githubusercontent.com/alphatroya/884aef2590d3c873d4f0d447d6a95a3c/raw/8a2682772cf9a7625b680771cf9ad9106c6cf00e/pre-commit" > .git/hooks/pre-commit
ln -sf ../../hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "\nmint run xcodegen" >> .git/hooks/pre-commit
echo "git add {{ cookiecutter.name }}.xcodeproj" >> .git/hooks/pre-commit

## clean: Clean up project files
clean:
Expand Down
2 changes: 1 addition & 1 deletion {{ cookiecutter.name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Also, some secret environment parameters need to be set:
The project was generated using the [cookiecutter tool](https://github.com/audreyr/cookiecutter)
and [this](https://github.com/alphatroya/swift-project-template) swift template.

Template version: 1.2.6
Template version: 1.2.7

## AppStore credentials

Expand Down
11 changes: 11 additions & 0 deletions {{ cookiecutter.name }}/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
git diff --diff-filter=d --staged --name-only | grep -e '\.swift$' | while read line; do
if [[ $line == *"/Generated"* ]]; then
echo "IGNORING GENERATED FILE: " "$line";
else
mint run swiftformat swiftformat "${line}";
git add "$line";
fi
done
mint run xcodegen
git add {{ cookiecutter.name }}.xcodeproj

0 comments on commit 7a3f843

Please sign in to comment.