Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Swiftlint to git pre-commit #6

Merged
merged 8 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class dydxMarketInfoViewBuilder: NSObject, ObjectBuilderProtocol {

private class dydxMarketInfoViewController: HostingViewController<PlatformView, dydxMarketInfoViewModel> {
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool {
if (request?.path == "/trade" || request?.path == "/market"), let presenter = presenter as? dydxMarketInfoViewPresenter {
if (request?.path == "/trade" || request?.path == "/market"), let presenter = presenter as? dydxMarketInfoViewPresenter {
presenter.marketId = request?.params?["market"] as? String ?? "ETH-USD"
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
if request?.path == "/trade" {
Expand Down Expand Up @@ -133,8 +133,8 @@ private class dydxMarketInfoViewPresenter: HostedViewPresenter<dydxMarketInfoVie
Publishers
.CombineLatest(AbacusStateManager.shared.state.selectedSubaccountPositions,
$marketId
.compactMap { $0 }
.removeDuplicates())
.compactMap { $0 }
.removeDuplicates())
.sink { [weak self] subaccountPositions, marketId in
let position = subaccountPositions.first { (subaccountPosition: SubaccountPosition) in
subaccountPosition.id == marketId
Expand All @@ -154,7 +154,7 @@ private class dydxMarketInfoViewPresenter: HostedViewPresenter<dydxMarketInfoVie
/*
Comment out for now. Close Position would cause this to trigger and stops orderbook
*/
// AbacusStateManager.shared.setMarket(market: nil)
// AbacusStateManager.shared.setMarket(market: nil)
}

private func updatePositionSection(position: SubaccountPosition?) {
Expand All @@ -181,7 +181,7 @@ private class dydxMarketInfoViewPresenter: HostedViewPresenter<dydxMarketInfoVie
}
} else if presenter.isStarted {
presenter.stop()
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

ROOT_DIR=$(pwd)/../../

cp pre-commit ../.git/hooks

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Expand Down
17 changes: 17 additions & 0 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Redirect output to stderr.
exec 1>&2

# Stash any unstaged changes
git stash -q --keep-index

# Run SwiftLint only on staged files
git diff --cached --name-only --diff-filter=ACM | grep "\.swift$" | while read file; do
swiftlint --fix --format "$file" 2>/dev/null
done

# Stash the unstaged changes that were stashed previously
git stash pop -q

exit 0
Loading