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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
<?xml version="1.0"?>
<!-- ======================================================================
ANT Macrodef Build Script
- Runs various GitHub tasks
Author: Newtriks <simon@newtriks.com>
Date: 6th March 2010
This script is based on code written by:
Mark Lowe <melowe@gmail.com>
Tom Robinson <http://tlrobinson.net>
Scripts ripped from:
<http://tlrobinson.net/blog/2008/11/13/ant-tasks-for-git/>
and Comment by Timo on the above URL
====================================================================== -->
<project>
<!-- = = = = = = = = = = = = = = = = =
macrodef: git
= = = = = = = = = = = = = = = = = -->
<macrodef name="git">
<attribute name = "command" />
<attribute name = "dir" default = "" />
<element name = "args" optional = "true" />
<sequential>
<echo file="GIT_COMMAND_LOG" message="git @{command} 
"
append="yes" />
<exec executable = "git" dir = "@{dir}" logerror="true" >
<arg value = "@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
<macrodef name = "git-init">
<attribute name = "repository" />
<sequential>
<git command = "init">
<args>
<arg value = "@{repository}" />
</args>
</git>
</sequential>
</macrodef>
<macrodef name = "git-export">
<attribute name = "revision" />
<attribute name = "destinationDirectory" />
<sequential>
<exec executable = "${buildsupport.basedir}/gitant/git-export.sh" logerror="true" >
<arg value = "@{revision}" />
<arg value = "@{destinationDirectory}" />
</exec>
</sequential>
</macrodef>
<macrodef name = "git-add">
<attribute name = "path" />
<attribute name = "target" />
<sequential>
<git command = "add" dir="@{path}">
<args>
<arg value = "@{target}" />
</args>
</git>
</sequential>
</macrodef>
<macrodef name = "git-commit">
<attribute name = "path" />
<attribute name = "message" />
<sequential>
<git command="commit" dir="@{path}">
<args>
<arg value= "@{message}" />
</args>
</git>
</sequential>
</macrodef>
<macrodef name = "git-clone-pull">
<attribute name = "repository" />
<attribute name = "dest" />
<sequential>
<git command = "clone">
<args>
<arg value = "@{repository}" />
<arg value = "@{dest}" />
</args>
</git>
<git command = "pull" dir = "@{dest}" />
</sequential>
</macrodef>
<macrodef name = "git-remote-add">
<attribute name = "path" />
<attribute name = "branch" />
<attribute name = "repository" />
<sequential>
<echo file="DUMP" message="branch: @{branch} repos: @{repository}"/>
<git command = "remote" dir="@{path}">
<args>
<arg value = "add" />
<arg value = "@{branch}" />
<arg value = "@{repository}" />
</args>
</git>
</sequential>
</macrodef>
<macrodef name = "git-push">
<attribute name = "path" />
<attribute name = "branch" />
<attribute name = "head" />
<sequential>
<git command = "push" dir="@{path}">
<args>
<arg value = "@{branch}" />
<arg value = "@{head}" />
</args>
</git>
</sequential>
</macrodef>
<macrodef name="test">
<attribute name = "path" default="hello" />
<sequential>
<fail message="fail">
<condition>
<not>
<contains string="@{path}" substring="hello" />
</not>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="git-revision">
<attribute name="path" />
<attribute name="output" />
<sequential>
<exec executable="git" outputproperty="head" dir = "@{path}">
<arg value="rev-parse" />
<arg value="HEAD" />
</exec>
<echo file="GIT_REVISION_LOG" message="Found revision: ${head}"/>
<exec executable="git" outputproperty="dirty">
<arg value="diff" />
<arg value="--shortstatt" />
</exec>
<condition property="@{output}" value="${head}" else="${head} (dirty)">
<equals arg1="${dirty}" arg2="" />
</condition>
</sequential>
</macrodef>
</project>
|