All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.koshinuke.jgit.GGitUtil.groovy Maven / Gradle / Ivy

The newest version!
package org.koshinuke.jgit

import javax.annotation.Nonnull

import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Repository
import org.koshinuke.util.LifecycleFunctions

/**
 * @author taichi
 */
class GGitUtil {

	public static  R handle(@Nonnull Git git, @Nonnull Closure closure) {
		Objects.requireNonNull(git)
		return handle(git.getRepository(), closure)
	}

	public static  R handle(@Nonnull Repository repo, @Nonnull Closure closure) {
		Objects.requireNonNull(repo)
		return LifecycleFunctions.handle({repo}, {it.close()}, closure)
	}

	public static  R lockDirCache(@Nonnull Repository repo, @Nonnull Closure closure) {
		Objects.requireNonNull(repo)
		return LifecycleFunctions.handle({ repo.lockDirCache() }, { it.unlock() }, closure)
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy