Skip to content

Commit 3cc8d0a

Browse files
committed
Updates- new JGit, etc
1 parent 70b3ca6 commit 3cc8d0a

File tree

13 files changed

+46
-97
lines changed

13 files changed

+46
-97
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@ jobs:
1313
test:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v3
18-
- name: Setup JDK
19-
uses: actions/setup-java@v3
20-
with:
21-
distribution: corretto
22-
java-version: 11
23-
cache: sbt
16+
- uses: actions/checkout@v4
17+
- uses: guardian/setup-scala@v1
2418
- name: Build and Test
2519
run: sbt -v test
2620
- name: Test Summary

BUILD.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ can run anywhere Java can.
44
Here's a rough set of instructions for building the BFG, if you don't want to use the
55
pre-built [downloads](http://rtyley.github.io/bfg-repo-cleaner/#download):
66

7-
* Install Java JDK 8 or above
7+
* Install Java JDK 11 or above
88
* Install [sbt](https://www.scala-sbt.org/1.x/docs/Setup.html)
99
* `git clone [email protected]:rtyley/bfg-repo-cleaner.git`
1010
* `cd bfg-repo-cleaner`

bfg-library/src/main/scala/com/madgag/git/bfg/cleaner/LfsBlobConverter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.madgag.textmatching.{Glob, TextMatcher}
3030
import org.eclipse.jgit.internal.storage.file.FileRepository
3131
import org.eclipse.jgit.lib.{ObjectId, ObjectReader}
3232

33-
import java.nio.charset.Charset
33+
import java.nio.charset.{Charset, StandardCharsets}
3434
import java.nio.file.{Files, Path}
3535
import scala.jdk.StreamConverters._
3636
import scala.util.{Try, Using}
@@ -50,7 +50,7 @@ class LfsBlobConverter(
5050

5151
val gitAttributesLine = s"$lfsGlobExpression filter=lfs diff=lfs merge=lfs -text"
5252

53-
implicit val UTF_8 = Charset.forName("UTF-8")
53+
implicit val UTF_8: Charset = StandardCharsets.UTF_8
5454

5555
val lfsPointerMemo = MemoUtil.concurrentCleanerMemo[ObjectId]()
5656

bfg-library/src/main/scala/com/madgag/git/bfg/model/Commit.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.eclipse.jgit.lib.Constants.OBJ_COMMIT
66
import org.eclipse.jgit.lib._
77
import org.eclipse.jgit.revwalk.RevCommit
88

9+
import java.nio.charset.StandardCharsets.UTF_8
910
import java.nio.charset.{Charset, IllegalCharsetNameException, UnsupportedCharsetException}
1011
import scala.jdk.CollectionConverters._
1112

@@ -59,10 +60,10 @@ case class CommitArcs(parents: Seq[ObjectId], tree: ObjectId) {
5960

6061
object CommitNode {
6162
def apply(c: RevCommit): CommitNode = CommitNode(c.getAuthorIdent, c.getCommitterIdent, c.getFullMessage,
62-
try c.getEncoding catch {case e @ (_ : IllegalCharsetNameException | _ : UnsupportedCharsetException) => Constants.CHARSET})
63+
try c.getEncoding catch {case e @ (_ : IllegalCharsetNameException | _ : UnsupportedCharsetException) => UTF_8})
6364
}
6465

65-
case class CommitNode(author: PersonIdent, committer: PersonIdent, message: String, encoding: Charset = Constants.CHARSET) {
66+
case class CommitNode(author: PersonIdent, committer: PersonIdent, message: String, encoding: Charset = UTF_8) {
6667
lazy val subject = message.linesIterator.to(LazyList).headOption
6768
lazy val lastParagraphBreak = message.lastIndexOf("\n\n")
6869
lazy val messageWithoutFooters = if (footers.isEmpty) message else (message take lastParagraphBreak)

bfg-library/src/test/scala/com/madgag/git/bfg/GitUtilSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ package com.madgag.git.bfg
2222

2323
import com.madgag.git._
2424
import com.madgag.git.test._
25+
import org.eclipse.jgit.internal.storage.file.FileRepository
2526
import org.scalatest.flatspec.AnyFlatSpec
2627
import org.scalatest.matchers.should.Matchers
2728

2829
class GitUtilSpec extends AnyFlatSpec with Matchers {
29-
implicit val repo = unpackRepo("/sample-repos/example.git.zip")
30+
implicit val repo: FileRepository = unpackRepo("/sample-repos/example.git.zip")
3031

3132
"reachable blobs" should "match expectations" in {
3233
implicit val (revWalk, reader) = repo.singleThreadedReaderTuple

bfg-test/src/main/scala/com/madgag/git/bfg/test/unpackedRepo.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package com.madgag.git.bfg.test
22

33
import com.madgag.git._
44
import com.madgag.git.test._
5-
import org.eclipse.jgit.internal.storage.file.{GC, ObjectDirectory}
5+
import org.eclipse.jgit.internal.storage.file.{FileRepository, GC, ObjectDirectory}
66
import org.eclipse.jgit.lib.Constants.OBJ_BLOB
77
import org.eclipse.jgit.lib.{ObjectId, ObjectReader, Repository}
8-
import org.eclipse.jgit.revwalk.{RevCommit, RevTree}
8+
import org.eclipse.jgit.revwalk.{RevCommit, RevTree, RevWalk}
99
import org.eclipse.jgit.treewalk.TreeWalk
1010
import org.scalatest.Inspectors
1111
import org.scalatest.flatspec.AnyFlatSpec
@@ -16,9 +16,9 @@ import scala.jdk.CollectionConverters._
1616

1717
class unpackedRepo(filePath: String) extends AnyFlatSpec with Matchers {
1818

19-
implicit val repo = unpackRepo(filePath)
20-
implicit val objectDirectory = repo.getObjectDatabase.asInstanceOf[ObjectDirectory]
21-
implicit lazy val (revWalk, reader) = repo.singleThreadedReaderTuple
19+
implicit val repo: FileRepository = unpackRepo(filePath)
20+
implicit val objectDirectory: ObjectDirectory = repo.getObjectDatabase
21+
implicit lazy val (revWalk: RevWalk, reader: ObjectReader) = repo.singleThreadedReaderTuple
2222

2323

2424
def blobOfSize(sizeInBytes: Int): Matcher[ObjectId] = Matcher { (objectId: ObjectId) =>
@@ -29,8 +29,8 @@ class unpackedRepo(filePath: String) extends AnyFlatSpec with Matchers {
2929
}
3030

3131
def packedBlobsOfSize(sizeInBytes: Long): Set[ObjectId] = {
32-
implicit val reader = repo.newObjectReader()
33-
repo.getObjectDatabase.asInstanceOf[ObjectDirectory].packedObjects.filter { objectId =>
32+
implicit val reader: ObjectReader = repo.newObjectReader()
33+
repo.getObjectDatabase.packedObjects.filter { objectId =>
3434
val objectLoader = objectId.open
3535
objectLoader.getType == OBJ_BLOB && objectLoader.getSize == sizeInBytes
3636
}.toSet

bfg/src/main/scala/com/madgag/git/bfg/cli/CLIConfig.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object CLIConfig {
4545
val parser = new OptionParser[CLIConfig]("bfg") {
4646

4747
def fileMatcher(name: String, defaultType: TextMatcherType = Glob) = {
48-
implicit val textMatcherRead = Read.reads { TextMatcher(_, defaultType) }
48+
implicit val textMatcherRead: Read[TextMatcher] = Read.reads { TextMatcher(_, defaultType) }
4949

5050
opt[TextMatcher](name).valueName(s"<${defaultType.expressionPrefix}>").validate { m =>
5151
if (m.expression.contains('/')) {
@@ -143,7 +143,7 @@ case class CLIConfig(stripBiggestBlobs: Option[Int] = None,
143143

144144
lazy val gitdir = resolveGitDirFor(repoLocation)
145145

146-
implicit lazy val repo = FileRepositoryBuilder.create(gitdir.get).asInstanceOf[FileRepository]
146+
implicit lazy val repo: FileRepository = FileRepositoryBuilder.create(gitdir.get).asInstanceOf[FileRepository]
147147

148148
lazy val objectProtection = ProtectedObjectCensus(protectBlobsFromRevisions)
149149

bfg/src/test/scala/com/madgag/git/bfg/cli/MainSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package com.madgag.git.bfg.cli
2323
import com.madgag.git._
2424
import com.madgag.git.bfg.cli.test.unpackedRepo
2525
import com.madgag.git.bfg.model._
26-
import org.eclipse.jgit.lib.ObjectId
26+
import org.eclipse.jgit.lib.{ObjectId, ObjectReader}
2727
import org.scalatest.flatspec.AnyFlatSpec
2828
import org.scalatest.matchers.should.Matchers
2929
import org.scalatest.{Inspectors, OptionValues}
@@ -36,7 +36,7 @@ class MainSpec extends AnyFlatSpec with Matchers with OptionValues with Inspecto
3636
// concurrent testing against scala.App is not safe https://twitter.com/rtyley/status/340376844916387840
3737

3838
"CLI" should "not change commits unnecessarily" in new unpackedRepo("/sample-repos/exampleWithInitialCleanHistory.git.zip") {
39-
implicit val r = reader
39+
implicit val r: ObjectReader = reader
4040

4141
ensureInvariantValue(commitHist() take 2) {
4242
ensureRemovalFrom(commitHist()).ofCommitsThat(haveCommitWhereObjectIds(contain(abbrId("294f")))) {
@@ -90,7 +90,7 @@ class MainSpec extends AnyFlatSpec with Matchers with OptionValues with Inspecto
9090
}
9191

9292
"strip blobs by id" should "work" in new unpackedRepo("/sample-repos/example.git.zip") {
93-
implicit val r = reader
93+
implicit val r: ObjectReader = reader
9494

9595
val badBlobs = Set(abbrId("db59"), abbrId("86f9"))
9696
val blobIdsFile = Files.createTempFile("test-strip-blobs",".ids")

build.sbt

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import Dependencies._
2-
import common._
1+
import Dependencies.*
32

43
ThisBuild / organization := "com.madgag"
54

6-
ThisBuild / scalaVersion := "2.13.10"
5+
ThisBuild / scalaVersion := "2.13.16"
76

87
ThisBuild / scalacOptions ++= Seq("-deprecation", "-feature", "-language:postfixOps")
98

10-
ThisBuild / licenses := Seq("GPLv3" -> url("http://www.gnu.org/licenses/gpl-3.0.html"))
11-
12-
ThisBuild / homepage := Some(url("https://github.com/rtyley/bfg-repo-cleaner"))
9+
ThisBuild / licenses := Seq(License.GPL3_or_later)
1310

1411
ThisBuild / resolvers ++= jgitVersionOverride.map(_ => Resolver.mavenLocal).toSeq
1512

@@ -20,30 +17,12 @@ ThisBuild / Test/testOptions += Tests.Argument(
2017
"-u", s"test-results/scala-${scalaVersion.value}"
2118
)
2219

23-
lazy val root = Project(id = "bfg-parent", base = file(".")) aggregate (bfg, bfgTest, bfgLibrary)
24-
25-
releaseSignedArtifactsSettings
26-
27-
lazy val bfgTest = bfgProject("bfg-test")
20+
lazy val root = Project(id = "bfg-parent", base = file(".")) aggregate (bfg, `bfg-test`, `bfg-library`)
2821

29-
lazy val bfgLibrary = bfgProject("bfg-library") dependsOn(bfgTest % Test)
22+
lazy val `bfg-test` = project
3023

31-
lazy val bfg = bfgProject("bfg") enablePlugins(BuildInfoPlugin) dependsOn(bfgLibrary, bfgTest % Test)
24+
lazy val `bfg-library` = project.dependsOn(`bfg-test` % Test)
3225

33-
lazy val bfgBenchmark = bfgProject("bfg-benchmark")
26+
lazy val bfg = project.enablePlugins(BuildInfoPlugin).dependsOn(`bfg-library`, `bfg-test` % Test)
3427

35-
ThisBuild / publishTo := sonatypePublishToBundle.value
36-
37-
ThisBuild / pomExtra := (
38-
<scm>
39-
<url>git@github.com:rtyley/bfg-repo-cleaner.git</url>
40-
<connection>scm:git:git@github.com:rtyley/bfg-repo-cleaner.git</connection>
41-
</scm>
42-
<developers>
43-
<developer>
44-
<id>rtyley</id>
45-
<name>Roberto Tyley</name>
46-
<url>https://github.com/rtyley</url>
47-
</developer>
48-
</developers>
49-
)
28+
lazy val `bfg-benchmark` = project

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.8.2
1+
sbt.version=1.10.7

0 commit comments

Comments
 (0)