Skip to content

Instantly share code, notes, and snippets.

@akhikhl
Created June 7, 2013 05:22
Show Gist options
  • Save akhikhl/5727210 to your computer and use it in GitHub Desktop.
Save akhikhl/5727210 to your computer and use it in GitHub Desktop.
Batch pull on all git-repositories found in the current folder
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'org.ajoberstar:gradle-git:0.5.0' }
}
import org.ajoberstar.gradle.git.tasks.*
def onEachGitFolder(File folder, Closure closure) {
File gitServiceFolder = new File(folder, ".git")
if(gitServiceFolder.exists() && gitServiceFolder.isDirectory())
closure(folder)
else
folder.eachDir { subFolder ->
onEachGitFolder(subFolder, closure);
}
}
task pull
onEachGitFolder projectDir, { folder ->
def taskName = folder.name + "_pull"
project.task (taskName, type: GitPull) {
setRepoPath folder.absolutePath
}
project.tasks.pull.dependsOn project.tasks[taskName]
}
defaultTasks "pull"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment