Skip to content

Commit a4bf088

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

File tree

18 files changed

+73
-106
lines changed

18 files changed

+73
-106
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

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
uses: guardian/gha-scala-library-release-workflow/.github/workflows/reusable-release.yml@v1
9+
permissions: { contents: write, pull-requests: write }
10+
with:
11+
GITHUB_APP_ID: 930725
12+
SONATYPE_PROFILE_NAME: 'com.madgag'
13+
SONATYPE_CREDENTIAL_HOST: 's01.oss.sonatype.org'
14+
secrets:
15+
SONATYPE_TOKEN: ${{ secrets.AUTOMATED_MAVEN_RELEASE_SONATYPE_TOKEN }}
16+
PGP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_PGP_SECRET }}
17+
GITHUB_APP_PRIVATE_KEY: ${{ secrets.AUTOMATED_MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY }}

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java corretto-11.0.25.9.1

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-benchmark/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Dependencies._
1+
import Dependencies.*
22

33
libraryDependencies ++= guava ++ Seq(
44
madgagCompress,

bfg-library/build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Dependencies._
1+
import Dependencies.*
22

33
libraryDependencies ++= guava ++ Seq(
44
parCollections,
@@ -9,6 +9,6 @@ libraryDependencies ++= guava ++ Seq(
99
slf4jSimple,
1010
lineSplitting,
1111
scalaGitTest % Test,
12-
"org.apache.commons" % "commons-text" % "1.9" % Test
12+
"org.apache.commons" % "commons-text" % "1.13.0" % Test
1313
)
1414

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

0 commit comments

Comments
 (0)