pl.allegro.tech.build.axion.release.infrastructure.git.GitChangesPrinter.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axion-release-plugin Show documentation
Show all versions of axion-release-plugin Show documentation
Gradle release and version management plugin
package pl.allegro.tech.build.axion.release.infrastructure.git
import org.eclipse.jgit.api.Status
import pl.allegro.tech.build.axion.release.domain.scm.ScmChangesPrinter
import pl.allegro.tech.build.axion.release.infrastructure.output.OutputWriter
class GitChangesPrinter implements ScmChangesPrinter {
private final OutputWriter output = new OutputWriter()
private final GitRepository repository
GitChangesPrinter(GitRepository repository) {
this.repository = repository
}
@Override
void printChanges() {
Status status = repository.listChanges()
outputHeader('Staged changes:')
printChangeset('modified', status.changed)
printChangeset('added', status.added)
printChangeset('removed', status.removed)
outputHeader('Unstaged changes:')
printChangeset('modified', status.modified)
printChangeset('added', status.untracked)
printChangeset('removed', status.missing)
output.println()
}
private void printChangeset(String type, Set changes) {
if (!changes.empty) {
changes.each { outputLine(type, it) }
}
}
private void outputHeader(String text) {
output.println('')
output.println(text)
}
private void outputLine(String description, String file) {
output.println(" $description: $file")
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy