Skip to content

Commit

Permalink
Rename script
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Aug 4, 2023
1 parent 9c5193b commit ad4a2ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions DuckDuckGo/Autofill/ContentOverlayPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import BrowserServicesKit
@MainActor
public final class ContentOverlayPopover {

// Test change
public var zoomFactor: CGFloat?
public weak var currentTabView: NSView?

Expand Down
30 changes: 23 additions & 7 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/bash

FIX=false

if [[ "$1" == "--fix" ]]; then
FIX=true
fi

if [[ -n "$CI" ]]; then
echo "Skipping SwiftLint run in CI"
exit 0
fi

# Add brew into PATH
if [[ -f /opt/homebrew/bin/brew ]]; then
eval $(/opt/homebrew/bin/brew shellenv)
eval $(/opt/homebrew/bin/brew shellenv)
fi

run_swiftlint_for_modified_files () {
Expand All @@ -19,7 +25,7 @@ run_swiftlint_for_modified_files () {
do
# collect .swift files separately for Unit Tests and Code Files
if [[ "${FILE_NAME##*.}" == "swift" ]]; then
# check if file exists (replacing back #001 with space)
# check if file exists (replacing back #001 with space)
if [ -f "`echo "${FILE_NAME}" | tr '\001' ' '`" ]; then
if [[ "$FILE_NAME" == *"Tests/"* ]]; then
TEST_FILES+=" \"${FILE_NAME}\""
Expand All @@ -30,18 +36,28 @@ run_swiftlint_for_modified_files () {
fi
done

SWIFTLINT_COMMAND="swiftlint lint"
if $FIX; then
SWIFTLINT_COMMAND="swiftlint lint --fix"
fi

if [ -n "${CODE_FILES}" ]; then
# replace back #001 with space and feed to swiftlint
echo "${CODE_FILES}" | tr '\001' ' ' | xargs swiftlint lint
# replace back #001 with space and feed to swiftlint
echo "${CODE_FILES}" | tr '\001' ' ' | xargs $SWIFTLINT_COMMAND
fi
if [ -n "${TEST_FILES}" ]; then
echo "${TEST_FILES}" | tr '\001' ' ' | xargs swiftlint lint --config .swiftlint.tests.yml
echo "${TEST_FILES}" | tr '\001' ' ' | xargs $SWIFTLINT_COMMAND --config .swiftlint.tests.yml
fi
}

if which swiftlint >/dev/null; then
if [ "$CONFIGURATION" = "Release" ]; then
swiftlint lint --strict
if $FIX; then
swiftlint lint --fix --strict
else
swiftlint lint --strict
fi

if [ $? -ne 0 ]; then
echo "error: SwiftLint validation failed."
exit 1
Expand All @@ -52,4 +68,4 @@ if which swiftlint >/dev/null; then
else
echo "error: SwiftLint not installed. Install using \`brew install swiftlint\`"
exit 1
fi
fi
2 changes: 1 addition & 1 deletion scripts/swiftlint-hook.sh → scripts/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# URL where the installation/uninstallation script is hosted
SCRIPT_URL="https://raw.githubusercontent.com/duckduckgo/BrowserServicesKit/daniel/swiftlint-hook/scripts/swiftlint-hook.sh"
SCRIPT_URL="https://raw.githubusercontent.com/duckduckgo/BrowserServicesKit/daniel/swiftlint-hook/scripts/pre-commit.sh"
LOCAL_SCRIPT="local-install-pre-commit-hook.sh"

# Check the argument for install or uninstall
Expand Down

0 comments on commit ad4a2ef

Please sign in to comment.