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

Use T.workspace in Git.open() #93

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import com.goyeau.mill.scalafix.StyleModule
import de.tobiasroeser.mill.integrationtest._
import mill._
import mill.scalalib._
import mill.scalalib.api.Util.scalaNativeBinaryVersion
import mill.scalalib.api.ZincWorkerUtil.scalaNativeBinaryVersion
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Util is deprecated

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
import org.typelevel.scalacoptions.ScalacOptions._
import org.typelevel.scalacoptions.{ScalaVersion, ScalacOptions}

val millVersions = Seq("0.10.12", "0.11.1")
val millVersions = Seq("0.10.12", "0.11.1", "0.12.4")
def millBinaryVersion(millVersion: String) = scalaNativeBinaryVersion(millVersion)

object `mill-git` extends Cross[MillGitCross](millVersions: _*)
Expand Down
104 changes: 52 additions & 52 deletions itest/src/custom/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,59 @@ object project extends JavaModule {
def setupUncommittedChanges = T.input {
remove.all(pwd / ".git")

proc("git", "init").call()
proc("git", "init").call(cwd = T.workspace)
}
def uncommittedChanges() = T.command {
setupUncommittedChanges()

assert("""[\da-f]{7}""".r.findFirstIn(project.jobVersion()).isDefined)

remove.all(pwd / ".git")
remove.all(T.workspace / ".git")
}

// Commit without tag
def setupCommitWithoutTag = T.input {
remove.all(pwd / ".git")
remove.all(T.workspace / ".git")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
}
def commitWithoutTag() = T.command {
setupCommitWithoutTag()

val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(project.jobVersion() == hash)

remove.all(pwd / ".git")
remove.all(T.workspace / ".git")
}

// Uncommitted changes after commit without tag
def setupUncommittedChangesAfterCommitWithoutTag = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
write(pwd / "some-file", "Some change!")
proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
}
def uncommittedChangesAfterCommitWithoutTag() = T.command {
setupUncommittedChangesAfterCommitWithoutTag()

assert("""[\da-f]{7}""".r.findFirstIn(project.jobVersion()).isDefined)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(!project.jobVersion().contains(hash))
}

// Head tagged
def setupHeadTagged = T.input {
remove.all(pwd / ".git")
remove.all(T.workspace / ".git")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
}
def headTagged() = T.command {
setupHeadTagged()
Expand All @@ -74,61 +74,61 @@ def headTagged() = T.command {

// Uncommitted changes after tag
def setupUncommittedChangesAfterTag = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
write(pwd / "some-file", "Some change!")
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
}
def uncommittedChangesAfterTag() = T.command {
setupUncommittedChangesAfterTag()

assert("""1\.0\.0-1-[\da-f]{7}""".r.findFirstIn(project.jobVersion()).isDefined)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(!project.jobVersion().contains(hash))
}

// Commit after tag
def setupCommitAfterTag = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
write(pwd / "some-file", "Some change!")
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit 2").call()
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit 2").call(cwd = T.workspace)
}
def commitAfterTag() = T.command {
setupCommitAfterTag()

val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(project.jobVersion() == s"1.0.0-1-$hash")
}

// Uncommitted changes after tag and after commit
def setupUncommittedChangesAfterTagAndCommit = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
write(pwd / "some-file", "Some change!")
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit 2").call()
write.over(pwd / "some-file", "Some change 2!")
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit 2").call(cwd = T.workspace)
write.over(T.workspace / "some-file", "Some change 2!")
}
def uncommittedChangesAfterTagAndCommit() = T.command {
setupUncommittedChangesAfterTagAndCommit()

assert("""1\.0\.0-2-[\da-f]{7}""".r.findFirstIn(project.jobVersion()).isDefined)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(!project.jobVersion().contains(hash))
}
102 changes: 51 additions & 51 deletions itest/src/docker/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ object project extends JavaModule with GitTaggedDockerModule {

// Uncommitted changes
def setupUncommittedChanges = T.input {
remove.all(pwd / ".git")
remove.all(T.workspace / ".git")

proc("git", "init").call()
proc("git", "init").call(cwd = T.workspace)
}
def uncommittedChanges() = T.command {
setupUncommittedChanges()
Expand All @@ -29,16 +29,16 @@ def uncommittedChanges() = T.command {

// Commit without tag
def setupCommitWithoutTag = T.input {
remove.all(pwd / ".git")
remove.all(T.workspace / ".git")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
}
def commitWithoutTag() = T.command {
setupCommitWithoutTag()

val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
val tags = project.docker.tags()
assert(tags.size == 2)
assert(tags(0) == s"project:$hash")
Expand All @@ -47,33 +47,33 @@ def commitWithoutTag() = T.command {

// Uncommitted changes after commit without tag
def setupUncommittedChangesAfterCommitWithoutTag = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
write(pwd / "some-file", "Some change!")
proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
}
def uncommittedChangesAfterCommitWithoutTag() = T.command {
setupUncommittedChangesAfterCommitWithoutTag()

val tags = project.docker.tags()
assert(tags.size == 2)
assert("""project:[\da-f]{7}""".r.findFirstIn(tags(0)).isDefined)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(!tags(0).contains(hash))
assert(tags(1) == "project:latest")
}

// Head tagged
def setupHeadTagged = T.input {
remove.all(pwd / ".git")
remove.all(T.workspace / ".git")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
}
def headTagged() = T.command {
setupHeadTagged()
Expand All @@ -86,70 +86,70 @@ def headTagged() = T.command {

// Uncommitted changes after tag
def setupUncommittedChangesAfterTag = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
write(pwd / "some-file", "Some change!")
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
}
def uncommittedChangesAfterTag() = T.command {
setupUncommittedChangesAfterTag()

val tags = project.docker.tags()
assert(tags.size == 2)
assert("""project:1\.0\.0-1-[\da-f]{7}""".r.findFirstIn(tags(0)).isDefined)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(!tags(0).contains(hash))
assert(tags(1) == "project:latest")
}

// Commit after tag
def setupCommitAfterTag = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
write(pwd / "some-file", "Some change!")
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit 2").call()
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit 2").call(cwd = T.workspace)
}
def commitAfterTag() = T.command {
setupCommitAfterTag()

val tags = project.docker.tags()
assert(tags.size == 2)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(tags(0) == s"project:1.0.0-1-$hash")
assert(tags(1) == "project:latest")
}

// Uncommitted changes after tag and after commit
def setupUncommittedChangesAfterTagAndCommit = T.input {
remove.all(pwd / ".git")
remove(pwd / "some-file")

proc("git", "init").call()
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit").call()
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call()
write(pwd / "some-file", "Some change!")
proc("git", "add", "--all").call()
proc("git", "commit", "-m", "Some commit 2").call()
write.over(pwd / "some-file", "Some change 2!")
remove.all(T.workspace / ".git")
remove(T.workspace / "some-file")

proc("git", "init").call(cwd = T.workspace)
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit").call(cwd = T.workspace)
proc("git", "tag", "-a", "v1.0.0", "-m", "v1.0.0").call(cwd = T.workspace)
write(T.workspace / "some-file", "Some change!")
proc("git", "add", "--all").call(cwd = T.workspace)
proc("git", "commit", "-m", "Some commit 2").call(cwd = T.workspace)
write.over(T.workspace / "some-file", "Some change 2!")
}
def uncommittedChangesAfterTagAndCommit() = T.command {
setupUncommittedChangesAfterTagAndCommit()

val tags = project.docker.tags()
assert(tags.size == 2)
assert("""project:1\.0\.0-2-[\da-f]{7}""".r.findFirstIn(tags(0)).isDefined)
val hash = proc("git", "rev-parse", "HEAD").call().out.trim().take(7)
val hash = proc("git", "rev-parse", "HEAD").call(cwd = T.workspace).out.trim().take(7)
assert(!tags(0).contains(hash))
assert(tags(1) == "project:latest")
}
Loading