Skip to content

Instantly share code, notes, and snippets.

@jonnycaley
Created December 16, 2020 12:09
Show Gist options
  • Save jonnycaley/ad196a3a258dfb0e271a4a261a646426 to your computer and use it in GitHub Desktop.
Save jonnycaley/ad196a3a258dfb0e271a4a261a646426 to your computer and use it in GitHub Desktop.
package com.dropbox.affectedmoduledetector
import java.io.File
class AffectedModuleConfiguration {
/**
* Folder to place the log in
*/
var logFolder: String? = null
/**
* Name for the log file
*/
var logFilename: String = "affected_module_detector.log"
/**
* Base directory to use for [pathsAffectingAllModules]
*/
var baseDir: String? = null
/**
* Files or folders which if changed will trigger all projects to be considered affected
*/
var pathsAffectingAllModules = setOf<String>()
set(value) {
requireNotNull(baseDir) {
"baseDir must be set to use pathsAffectingAllModules"
}
field = value
}
get() {
field.forEach { path ->
require(File(baseDir, path).exists()) {
"Could not find expected path in pathsAffectingAllModules: $path"
}
}
return field
}
/**
* Commit command which gets the commit sha to compare the changes agains
*/
var commitCommand: CommitCommand = PreviousCommitCommand()
companion object {
const val name = "affectedModuleDetector"
}
}
interface CommitCommand {
val command: String
}
class PreviousCommitCommand: CommitCommand {
override val command: String
get() = "git --no-pager rev-parse HEAD~1"
}
class ParentForkCommitCommand: CommitCommand {
override val command: String
get() = TODO("Not yet implemented")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment