"Take this shovel to dig in source code history for changes to specific methods and functions."
sbt-codeshovel
is available through Maven Central.
Add the sbt plugin to plugins.sbt
:
addSbtPlugin("io.github.jbwheatley" %% "sbt-codeshovel" % xxx)
and enable in build.sbt
:
enablePlugins(CodeShovelPlugin)
Start an sbt shell in the root of your repo, and run the following:
shovel ${path/to/the/file.scala} ${functionName} ${lineNumber} ${commit}
For example, to run against this function in pact4s starting from the HEAD commit:
shovel shared/src/main/scala/pact4s/StateChanger.scala handle 68 HEAD
sbt-codeshovel
also works for java
, js
and ts
files.
A .html
file will then be produced and placed in the /target
directory (e.g. /target/shovel-handle-68-HEAD.html
). Opening this in your
browser will allow you to browse the git history for the supplied method. Check the example here.
The core functionality of codeshovel is released as its own standalone library to be used with other build tools:
"io.github.jbwheatley" %% "codeshovel" % xxx
The method codeshovel.Execution.run
can be used to produce the html document:
run(
repositoryName = "pact4s",
baseDir = "/Users/jbwheatley/pact4s",
filePath = "shared/src/main/scala/pact4s/StateChanger.scala",
functionName = "handle",
startLine = 68,
startCommitName = "HEAD"
)
sbt-codeshovel
is a fork of ataraxie/codeshovel
which is based on research by the Software Practices Lab at UBC in Vancouver, Canada.
This plugin takes their excellent original work and extends it to work for scala functions, and makes it more convenient for everyday development needs.