-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
99 lines (85 loc) · 2.36 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.ajoberstar.grgit.*
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'org.ajoberstar:gradle-git:1.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task cloneGitRepo{
doLast{
Grgit.clone(dir: file('./repo'), uri: 'https://github.com/igomezal/Comunio.git')
Grgit.init(dir: file('./repo'))
}
}
task pull{
description 'Pull proyecto'
doLast{
def repo = Grgit.open(project.file('.'))
repo.checkout(branch:'master')
repo.pull()
}
}
task pushNuevaRama{
description 'Push proyecto'
doLast{
def repo = Grgit.open(project.file('.'))
def i = 0
def existe
def booleano = false
def branches = repo.branch.list()
while(branches.size()>i){
if(project.hasProperty("rama") && branches.get(i).getName()==rama){
existe = branches.get(i).getName()
booleano=true
}
if(branches.get(i).getName()=="rama-gradle"){
existe = branches.get(i).getName()
booleano=true
}
i++
}
if(booleano==true){
//repo.checkout(branch:'master')
repo.branch.remove(names:[existe],force:true)
}
if(project.hasProperty("rama") && (repo.branch.getCurrent().getName() != rama)){
repo.checkout(branch: rama,createBranch:true)
repo.commit(message: 'Cambios Gradle',all:true)
repo.push()
}else if(project.hasProperty("rama") && (repo.branch.getCurrent().getName() == rama)){
repo.commit(message: 'Cambios Gradle',all:true)
repo.push()
}else if(repo.branch.getCurrent().getName() == "rama-gradle"){
repo.commit(message: 'Cambios Gradle',all:true)
repo.push()
}else{
repo.checkout(branch: 'rama-gradle',createBranch:true)
repo.commit(message: 'Cambios Gradle',all:true)
repo.push()
}
def ramaObjetivo = repo.branch.getCurrent().getName()
repo.checkout(branch:'master')
print "Realizado push a la rama: ${ramaObjetivo} y actualmente se encuentra en la rama master"
}
}
task pushActual{
doLast{
def repo = Grgit.open(project.file('.'))
repo.commit(message: 'Cambios Gradle',all:true)
repo.push()
}
}