Skip to content

Commit

Permalink
Specify chmod as command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
jkstrauss committed Feb 8, 2018
1 parent f8cfc95 commit 7e08f52
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bfg/src/main/scala/com/madgag/git/bfg/cli/CLIConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ object CLIConfig {

c.copy(fixFilenameDuplicatesPreferring = ord)
}
fileMatcher(
opt[(String,TextMatcher)]("chmod"),
(t:(String,TextMatcher)) => t match {case (_,tm) => tm}
).
unbounded.
keyName("<-x|+x>").
text("change executable mode of files matching glob; option may be specified multiple times, and will be processed in order specified. e.g.,--chmod:-x=*.* --chmod:+x=*.{sh,.pl} will make all files non-executable except *.sh and *.pl files").
action { (v, c) => c.copy(chmod = c.chmod :+ (v match {
case ("+x", fm) => (ExecutableFile, fm)
case ("-x", fm) => (RegularFile, fm)
case other => throw new IllegalArgumentException(s"'$other' should be '+x' or '-x'")
}))}
arg[File]("<repo>") optional() action { (x, c) =>
c.copy(repoLocation = x) } text("file path for Git repository to clean")
}
Expand All @@ -141,7 +153,8 @@ case class CLIConfig(stripBiggestBlobs: Option[Int] = None,
strictObjectChecking: Boolean = false,
sensitiveData: Option[Boolean] = None,
massiveNonFileObjects: Option[Long] = None,
repoLocation: File = new File(System.getProperty("user.dir"))) {
repoLocation: File = new File(System.getProperty("user.dir")),
chmod: Seq[(BlobFileMode, TextMatcher)] = Seq()) {

lazy val gitdir = resolveGitDirFor(repoLocation)

Expand Down Expand Up @@ -223,7 +236,9 @@ case class CLIConfig(stripBiggestBlobs: Option[Int] = None,
}
}

Seq(blobsByIdRemover, blobRemover, fileDeletion, blobTextModifier, lfsBlobConverter).flatten
lazy val chmodCleaner = if(chmod isEmpty) None else Some(new Chmoder(chmod))

Seq(blobsByIdRemover, blobRemover, fileDeletion, blobTextModifier, lfsBlobConverter, chmodCleaner).flatten
}

lazy val definesNoWork = treeBlobCleaners.isEmpty && folderDeletion.isEmpty && treeEntryListCleaners.isEmpty
Expand Down

0 comments on commit 7e08f52

Please sign in to comment.