Skip to content

Commit b748878

Browse files
authored
Remove assumption about repo name by using git (#3715)
to get the path of the top level of the repo ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> Fixing issue with test workspaces that would break if the repo is not named `smithy-rs` ## Description <!--- Describe your changes in detail --> Moved to using `git rev-parse --show-toplevel` to get the project directory instead of climbing the file tree. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> All of our CI tests this since it is part of generating test workspaces ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 21c6cc7 commit b748878

File tree

1 file changed

+2
-6
lines changed
  • codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil

1 file changed

+2
-6
lines changed

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,8 @@ object TestWorkspace {
8787
private val subprojects = mutableListOf<String>()
8888

8989
private val cargoLock: File by lazy {
90-
var curFile = File(this.javaClass.protectionDomain.codeSource.location.path)
91-
while (!curFile.endsWith("smithy-rs")) {
92-
curFile = curFile.parentFile
93-
}
94-
95-
curFile.resolve("aws/sdk/Cargo.lock")
90+
val projectDir = "git rev-parse --show-toplevel".runCommand().replace("\n", "")
91+
File(projectDir).resolve("aws/sdk/Cargo.lock")
9692
}
9793

9894
init {

0 commit comments

Comments
 (0)