-
Notifications
You must be signed in to change notification settings - Fork 231
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
Ability To Turn Off Formatting For Subdirectory #873
Open
samdeane
wants to merge
22
commits into
swiftlang:main
Choose a base branch
from
elegantchaos:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d7fa663
Initial stab at option to disable all formatting.
samdeane 049828c
Updated config documentation in README.
samdeane 4bd052c
Fixed typo, initialiser.
samdeane 1009582
Documented allDisabled key
samdeane 7275d90
Emit unmodified source if allDisabled is true.
samdeane fc2e249
Don't lint if allDisabled is set.
samdeane c2bb934
Change flag to skipAll.
samdeane 101e80e
Tweaked docs
samdeane ce9dd11
Check for suppression file first.
samdeane f54a359
Use .swift-format-ignore as the file name.
samdeane 853b910
Move suppression logic up to FileIterator
samdeane 549fafe
Removed spurious newlines
samdeane 337aad4
Filter urls to remove ignored ones.
samdeane ed63007
Tweaked readme.
samdeane bf42ce7
Removed obsolete addition.
samdeane 8542e17
Lift isRoot extension as it's used in two places.
samdeane b0554ec
Oops - skipping initial directory...
samdeane c532d89
Documentation tweaks.
samdeane c078ad9
Add minimal IgnoreFile abstraction.
samdeane 751ca4e
Comment for IgnoreFile class
samdeane 120a9c2
Added IgnoreFile unit tests
samdeane 43ebe84
Added test for nested directory.
samdeane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,27 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Foundation | ||
|
||
extension URL { | ||
var isRoot: Bool { | ||
#if os(Windows) | ||
// FIXME: We should call into Windows' native check to check if this path is a root once https://github.com/swiftlang/swift-foundation/issues/976 is fixed. | ||
// https://github.com/swiftlang/swift-format/issues/844 | ||
return self.pathComponents.count <= 1 | ||
#else | ||
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980 | ||
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed. | ||
return self.path == "/" || self.path == "" | ||
#endif | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More than just checking for the presence of the file, I think we go the extra step of validating that it only contains
*
so that users aren't surprised later when we add more functionality and it subtly changes the behavior based on those contents. If it contains anything else, we should throw an error saying it's the only supported form (and turn that into a nice human-readable error message when we exit).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to upgrade to gitignore like sytanx in the future, should we make the default value
**/*
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK,
*
is sufficient because according to the documentation:*
' matches anything except a slash.".gitignore
level."There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, got distracted, but am looking at this now.
One complication is that
FileIterator
doesn't throw, and instead relies on the caller to generate diagnostics for non-existent paths.In order to report invalid ignore files inside
FileIterator
we'd either need to be able to:I've gone for the third option, but it feels like a bit of a hack.