Skip to content

Instantly share code, notes, and snippets.

@bholota
Created July 8, 2015 12:42
Show Gist options
  • Save bholota/7a8c47577a91caf1255d to your computer and use it in GitHub Desktop.
Save bholota/7a8c47577a91caf1255d to your computer and use it in GitHub Desktop.
Add crashlyticsUpload tasks dependency on the fly - checking if everything is commited to git
//add it to your build.gradle
//every time when your will call task crashlyticsUploadSomethingSomething it will be called before it
//and it will crash if you have some uncommited changes in your working copy.
//
//I'm using this because I need git sha1 for app versioning in development versions.
task everythingGitCommited << {
def checkChanges = 'git status -uno --porcelain'.execute([], project.rootDir).text.trim()
if(checkChanges) {
throw new GradleException('Commit or shash your working copy before BETA upload!')
}
}
tasks.whenTaskAdded { task ->
if(task.name.startsWith("crashlyticsUpload")) {
task.dependsOn everythingGitCommited
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment