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

not working on project with multiple git repos #97

Open
wpc009 opened this issue Sep 8, 2015 · 5 comments
Open

not working on project with multiple git repos #97

wpc009 opened this issue Sep 8, 2015 · 5 comments

Comments

@wpc009
Copy link

wpc009 commented Sep 8, 2015

considering a sbt multi project Root (project created using repo):

root/
     build.sbt
     a/
         .git/
          some_a_file
     b/
         .git/
         some_b_file

Since, gitReader is defined under ThisBuild. All the projects share the same gitReader , which's baseDirectory is root/. And it can not find the valid git repo for project a, neither for b.

The same for a project constructed with multiple sub project using git submodule add <sub_project_repo_url> sub_project_name

@matanox
Copy link

matanox commented Jan 4, 2016

Indeed for a project with a git submodule, I am getting:

java.lang.RuntimeException: Setting value cannot be null: {file:/......}/*:gitCurrentBranch
    at scala.sys.package$.error(package.scala:27)
    at sbt.EvaluateSettings$INode.setValue(INode.scala:143)
    at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
    at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
    at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
    at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
    at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] Setting value cannot be null: {file:/......./*:gitCurrentBranch

@matanox
Copy link

matanox commented Jan 4, 2016

Using sbt inspect looks like this is coming from SbtGit.scala:87

>inspect gitCurrentBranch
[info] Setting: java.lang.String = master
[info] Description:
[info]  The current branch for this project.
[info] Provided by:
[info]  {file:/.......}/*:gitCurrentBranch
[info] Defined at:
[info]  (com.typesafe.sbt.SbtGit) SbtGit.scala:87
[info] Delegates:
[info]  pipeline/*:gitCurrentBranch
[info]  {.}/*:gitCurrentBranch
[info]  */*:gitCurrentBranch
[info] Related:
[info]  {.}/*:gitCurrentBranch

I cannot tell which version of the plugin the project is pulling in, as sbt-git does not show in the output of sbt plugins, and it is brought in programatically by some sbt plugin rather than being very explicitly added to the project. So I have not been able thus far to pinpoint the line of code.

@fawzi
Copy link

fawzi commented Feb 28, 2016

I came across this issue when trying to have the versions in my submodules.
In the end as I did not need all fallbacks and I could easily change the repos (just started them), I went simply with

version := {
    val gitV: String = Process("git" :: "describe" :: "--tags" :: Nil, baseDirectory.value) !!
    val hasUncheckedChanges: Boolean = (
      Process("git" :: "diff" :: "--no-ext-diff" :: "--quiet" :: "--exit-code" :: "HEAD" :: Nil).!
    ) != 0
    gitV.trim + (if (hasUncheckedChanges) "-SNAPSHOT" else "")
  } 

without sbt-git. Still I would welcome proper support in sbt-git...

@wpc009
Copy link
Author

wpc009 commented Mar 15, 2016

Supporting Multi-repo project can be done through this setting

GitKeys.gitReader in ThisProject <<= baseDirectory(base => new DefaultReadableGit(base)),

Add this to each sub-project's settings.
Then sub-project will using their own gitReader with it's baseDirectory as the DefaultReadableGit 's base.
This uses JGit.

@mslinn
Copy link

mslinn commented Nov 17, 2017

The syntax for the solution offered by @wpc009 for SBT v0.13.16+ is:

GitKeys.gitReader in ThisProject := baseDirectory(base => new DefaultReadableGit(base)).value,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants