-
Notifications
You must be signed in to change notification settings - Fork 507
Support scala-steward.conf
(makes sense in .github
and .config
folder)
#3115
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
Merged
mzuehlke
merged 1 commit into
scala-steward-org:main
from
mkurz:unprefixed-scala-steward.conf
Jul 11, 2023
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -264,7 +264,7 @@ class RepoConfigAlgTest extends FunSuite { | |
assert(clue(log).contains(startOfErrorMsg)) | ||
} | ||
|
||
test("config file in .github/") { | ||
test("hidden config file in .github/") { | ||
val repo = Repo("test", "dot-github-config") | ||
val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync() | ||
val rootConfigFile = repoDir / ".scala-steward.conf" | ||
|
@@ -278,7 +278,21 @@ class RepoConfigAlgTest extends FunSuite { | |
assert(config.maybeRepoConfig.isDefined) | ||
} | ||
|
||
test("config file in .config/") { | ||
test("not hidden config file in .github/") { | ||
val repo = Repo("test", "dot-github-config") | ||
val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync() | ||
val rootConfigFile = repoDir / "scala-steward.conf" | ||
val dotGithubConfigFile = repoDir / ".github" / "scala-steward.conf" | ||
val initialState = MockState.empty.addFiles(dotGithubConfigFile -> "").unsafeRunSync() | ||
val config = repoConfigAlg.readRepoConfig(repo).runA(initialState).unsafeRunSync() | ||
|
||
assert(!fileAlg.isRegularFile(rootConfigFile).unsafeRunSync()) | ||
assert(fileAlg.isRegularFile(dotGithubConfigFile).unsafeRunSync()) | ||
|
||
assert(config.maybeRepoConfig.isDefined) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests I added are basically just duplicates of the preceding test(s), just with the dot removed from the filename. |
||
|
||
test("hidden config file in .config/") { | ||
val repo = Repo("test", "dot-config-config") | ||
val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync() | ||
val rootConfigFile = repoDir / ".scala-steward.conf" | ||
|
@@ -292,6 +306,20 @@ class RepoConfigAlgTest extends FunSuite { | |
assert(config.maybeRepoConfig.isDefined) | ||
} | ||
|
||
test("not hidden config file in .config/") { | ||
val repo = Repo("test", "dot-config-config") | ||
val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync() | ||
val rootConfigFile = repoDir / "scala-steward.conf" | ||
val dotConfigConfigFile = repoDir / ".config" / "scala-steward.conf" | ||
val initialState = MockState.empty.addFiles(dotConfigConfigFile -> "").unsafeRunSync() | ||
val config = repoConfigAlg.readRepoConfig(repo).runA(initialState).unsafeRunSync() | ||
|
||
assert(!fileAlg.isRegularFile(rootConfigFile).unsafeRunSync()) | ||
assert(fileAlg.isRegularFile(dotConfigConfigFile).unsafeRunSync()) | ||
|
||
assert(config.maybeRepoConfig.isDefined) | ||
} | ||
|
||
test("log warning on multiple config files") { | ||
val repo = Repo("test", "multiple-config") | ||
val repoDir = workspaceAlg.repoDir(repo).unsafeRunSync() | ||
|
This file contains hidden or 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
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.
The fix is here: The
.substring(1)
removes the leading dot from the filename.As you can see I just append the possible non-hidden config file locations to the end of the list, which later will be searched for the first existing config file.
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.
Would it make sense to change the repoConfigBasename to be without the
.
instead, and then add the dot here? substring use here adds a bit of a mental overhead.PS: not associated with the project, but got a notification because of my PR and had to look at the code! Feel free to ignore :)
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.
The
repoConfigBasename
variable is publicly accessible therefore I don't want to change it's value for backwards compatibility.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.
makes sense!
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.
In line 46 of this file it maybe good to use the actual filename (
activeConfigFile
) instead ofrepoConfigBasename
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.
@mzuehlke Done and pushed, thanks!