-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
af: Add Git hook for future iOS/macOS file changes [SDK-4698] (#351)
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
staged_files=($(git diff --staged --name-only --diff-filter=ACDRT -- auth0_flutter/darwin)) | ||
|
||
# Only proceed if there are staged files from the 'darwin' directory | ||
if [ ${#staged_files[@]} -eq 0 ]; then | ||
exit 0 | ||
fi | ||
|
||
scripts/generate-symlinks.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
|
||
# This script generates symlinks for every file inside the 'darwin' directory | ||
# of the auth0_flutter package, to the 'ios' and 'macos' directories. | ||
# It's meant to be run from the repository root. | ||
|
||
set -euo pipefail | ||
|
||
repo_path=$(git rev-parse --show-toplevel) | ||
|
||
if [ "$repo_path" != $PWD ]; then | ||
echo 'This script must be run from the repository root' | ||
exit 1 | ||
fi | ||
|
||
base_dir='auth0_flutter' | ||
darwin_dir='auth0_flutter/darwin' | ||
files=($(find "$darwin_dir" -type f -print)) | ||
platforms=('ios' 'macos') | ||
|
||
for platform in "${platforms[@]}"; do | ||
rm -rf "$base_dir/$platform" | ||
done | ||
|
||
for file in "${files[@]}"; do | ||
for platform in "${platforms[@]}"; do | ||
target_file=$(echo "$file" | sed "s/darwin/$platform/") | ||
target_dir=$(dirname "$target_file") | ||
|
||
mkdir -p "$target_dir" | ||
|
||
case "$file" in | ||
# If it's a .gitignore file, copy it | ||
(*'.gitignore') cp -v "$file" "$target_dir" ;; | ||
# Else symlink it | ||
(*) ln -sv "$repo_path/$file" "$target_file" ;; | ||
esac | ||
done | ||
done | ||
|
||
for platform in "${platforms[@]}"; do | ||
git add "$base_dir/$platform" | ||
done |