Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Mar 1, 2022
1 parent 7a22bba commit 9843119
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,13 @@ object MergifyPlugin extends AutoPlugin {
githubWorkflowCheck := githubWorkflowCheck.dependsOn((ThisBuild / mergifyCheck)).value,
ThisBuild / mergifyLabelPaths := {
val labelPaths = (ThisBuild / mergifyLabelPaths).value
val label = projectLabel.value
def isRoot = label._2 ==
(LocalRootProject / baseDirectory).value.toPath
if (label._1.startsWith(".") || isRoot) { // don't label this project
labelPaths
} else {
val add = labelPaths.get(label._1) match {
case Some(path) => label._1 -> commonAncestor(path.toPath, label._2)
case None => label
}
labelPaths + (add._1 -> add._2.toFile)
projectLabel.value.fold(labelPaths) {
case (label, path) =>
val add = labelPaths.get(label) match {
case Some(f) => label -> commonAncestor(f.toPath, path)
case None => label -> path
}
labelPaths + (add._1 -> add._2.toFile)
}
}
)
Expand Down Expand Up @@ -155,7 +151,13 @@ object MergifyPlugin extends AutoPlugin {
.getOrElse(Seq.empty)
.map(_.toPath)
.foldLeft(baseDirectory.value.toPath)(commonAncestor(_, _))
path.getFileName.toString -> path

val label = path.getFileName.toString

def isRoot = path == (LocalRootProject / baseDirectory).value.toPath
if (label.startsWith(".") || isRoot) // don't label this project
None
else Some(label -> path)
}

// x and y should be absolute/normalized
Expand Down

0 comments on commit 9843119

Please sign in to comment.