This repository has been archived by the owner on Jun 15, 2018. It is now read-only.
/
build.xml
101 lines (94 loc) · 4.26 KB
/
build.xml
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
97
98
99
100
101
<?xml version="1.0" encoding="UTF-8"?>
<project name="phing-ext-gittasks" default="build">
<!-- add custom tasks from current directory -->
<taskdef name="gitdescribe" classname="GitDescribeTask" />
<taskdef name="gitdiff" classname="GitDiffTask" />
<taskdef name="gitlog" classname="GitLogTask" />
<taskdef name="gitremoteshow" classname="GitRemoteShowTask" />
<taskdef name="gittag" classname="GitTagTask" />
<!-- assume our current directory IS the git repo to operate on -->
<property name="repo.dir" value="." />
<resolvepath propertyName="repo.dir.resolved" file="${repo.dir}" />
<!-- demonstrate task for git-describe command -->
<target name="gitdescribe">
<echo msg="Equivalent to `git describe --all --long --always`" />
<gitdescribe repository="${repo.dir.resolved}"
all="true"
long="true"
always="true" />
<echo msg="Equivalent to `git describe --tags --abbrev=0 --match *-complete`" />
<gitdescribe repository="${repo.dir.resolved}"
tags="true"
abbrev="0"
match="*-complete"
outputProperty="gitDescribeOutput" />
<echo msg="Latest tag matching *-complete: ${gitDescribeOutput}" />
</target>
<!-- demonstrate task for git-describe command -->
<target name="gitdiff">
<echo msg="Equivalent to `git diff --shortstat --ignore-submodules HEAD^..HEAD`" />
<gitdiff repository="${repo.dir.resolved}"
shortstat="true"
ignoreSubmodules="true"
commits="HEAD^..HEAD"
outputProperty="gitDiffOutput" />
<echo msg="Files affected since HEAD^: ${gitDiffOutput}" />
<echo msg="Equivalent to `git diff --cached`" />
<gitdiff repository="${repo.dir.resolved}"
cached="true"
outputProperty="gitDiffOutput" />
<if>
<equals arg1="${gitDiffOutput}" arg2="" />
<then>
<echo msg="No staged changes!" />
</then>
<else>
<echo msg="Currently staged changes: ${gitDiffOutput}" />
</else>
</if>
</target>
<!-- demonstrate task for git-log command -->
<target name="gitlog">
<echo msg="Equivalent to `git log --name-status --format=oneline HEAD^..HEAD`" />
<gitlog repository="${repo.dir.resolved}"
nameStatus="true"
format="oneline"
since="HEAD^"
until="HEAD"
outputProperty="gitLogOutput" />
<echo msg="Everything that's happened since HEAD^: ${gitLogOutput}" />
</target>
<!-- demonstrate task for git-remote-show command -->
<target name="gitremoteshow">
<echo msg="Equivalent to `git remote show origin`" />
<gitremoteshow repository="${repo.dir.resolved}"
name="origin"
outputProperty="gitRemoteShowOutput" />
<echo msg="All the dirt we have on origin: ${gitRemoteShowOutput}" />
</target>
<!-- demonstrate task for git-tag command -->
<target name="gittag">
<echo msg="Equivalent to `git tag -a -m 'foo bar baz' MyUnsignedTag`" />
<gittag repository="${repo.dir.resolved}"
annotate="true"
message="foo bar baz"
name="MyUnsignedTag" />
<echo msg="Equivalent to `git tag -a -f -m 'fizz buzz' MyUnsignedTag`" />
<gittag repository="${repo.dir.resolved}"
annotate="true"
replace="true"
message="fizz buzz"
name="MyUnsignedTag" />
<echo msg="Equivalent to `git tag -l`" />
<gittag repository="${repo.dir.resolved}"
list="true"
outputProperty="gitTagOutput" />
<echo msg="All current tags: ${gitTagOutput}" />
<echo msg="Equivalent to `git tag -d MyUnsignedTag`" />
<gittag repository="${repo.dir.resolved}"
delete="true"
name="MyUnsignedTag" />
</target>
<!-- do them all by default -->
<target name="build" depends="gitdescribe,gitdiff,gitlog,gitremoteshow,gittag" />
</project>