sbt-groll
sbt-groll copied to clipboard
Let `groll` commands ignore certain files
My usecase is as follows:
I'm using groll next
to go to the next commit. I'm also using koan
which stores a file .koan.properties
in the repository folder. When doing groll next
this file is removed (as expected).
Is it possible to let groll next
ignore this .koan.properties
file somehow?
No, that's not possible yet. As the original author of sbt-groll and sbt-koan, I don't understand why you would use both in combination, because both essentially do the same with sbt-koan restricting its magic on a portion – the tests – of the source tree. OTOH this feature might be useful in a more general context, so adding a configurable set of files or paths that are ignored by sbt-groll seems like a nice feature. PRs are welcome ;-)
I am teaching a class. I want to use groll to roll forward the examples. Then use koan to let it add the new tests and implement the solution in front of the class using the provided tests. At a later time use groll again for some later exercises, without losing my koan state.
Another use case could be to have a scala worksheet in the project, which you don't want to have cleared in between.
I hear you. Yet groll and koan will get out of sync, so if you use groll n times you would have to use koan n+1 times to forward to the tests for the next exercise. For this use case I think it would be better to allow groll to only forward the tests. WDYT? The worksheet use case makes a lot of sense.
That makes sense. groll next tests-only
which only rolls forward the test directory. Although this does not map nice to the current git backend.
For me I have almost no control on what the next groll next
will contain. Sometimes, I want to roll forward everything, sometimes only the tests.
What do you mean with "Although this does not map nice to the current git backend."?
If I understand correctly, sbt-groll uses a git backend to do the groll next
and groll prev
and this corresponds to respectively going forward or back one commit. If we would need to filter folders here, I'm not sure how easy it would be to go forward one commit, but not doing this for the tests folder for example.
Something like git checkout id -- src/test
should do the job.
That's probably not enough. If build files change, these need to be forwarded, too. Maybe do a proper checkout of everything first and reset src/main then ...
Hi @hseeberger, after speaking with you tonight, I immediately tried it out. Unfortunately this didn't do the trick yet.
koan next
creates .koan.properties
, which I can add to .gitignore
.
The current code does (https://github.com/sbt/sbt-groll/blob/master/src/main/scala/de/heikoseeberger/sbtgroll/Groll.scala#L164):
case Some((id, message)) =>
git.resetHard()
git.clean()
This means the resetHard()
will reset the .gitignore.
clean()
will then remove the .koan.properties
. These are both implemented with the correct flags so it will not delete the files in .gitignore
If I actually commit the change to .gitignore
it will complain on doing groll next
:
sbt> groll next
[warn] Current commit "b508bca" is not within the history defined by "some-course-1.1.2": Use "head", "initial" or "move"!
It seems to me that this can work, but it means the .koan.properties
will have to be added to .gitignore
in the course repository. Do you also think this will work?
Yep, that's what I meant: adding .koan.properties to .gitignore in the course repo should do the trick.
@lutzh, could you give that a try, please?