Skip to content

Commit

Permalink
Merge pull request #10 from CrazyAwesomeCompany/feature/git
Browse files Browse the repository at this point in the history
Add git changeset target
  • Loading branch information
ngroot committed Jan 20, 2016
2 parents 78cbc47 + ad3e38f commit fd55818
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ A lot of the AutoPhing build files use configuration parameters to run the comma
+ [CSSLint](lib/csslint/README.md)
+ DBDeploy
+ Doctrine
+ [Git](lib/git/README.md)
+ [Java](lib/java/README.md)
+ [JSLint](lib/jslint/README.md)
+ Memcached
Expand Down
17 changes: 17 additions & 0 deletions lib/git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# AutoPhing Git

Perform Git commands

## Targets ##

### git-changeset-files ###
Get the files from a git diff. The results are stored in the `files.changeset` and `files.changeset.php` properties.

An example usage of this command is to get the changed PHP files for a Pull Request and run quality checks only
against the changeset.

## Configuration ##

+ `git.file` - The Git binary file
+ `git.revision` - The Git revision to compare
+ `git.base.revision` - The Git revision use as base
3 changes: 3 additions & 0 deletions lib/git/git.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
git.file=git

git.base.revision=develop
34 changes: 34 additions & 0 deletions lib/git/git.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="git" default="git-changeset-files" basedir=".">
<property file="${phing.dir.git}/git.properties" />

<target name="git-changeset-files">
<fail unless="git.revision" message="No valid git revision given"/>

<exec executable="${git.file}" outputProperty="changesetfiles">
<arg value="diff"/>
<arg value="--name-only"/>
<arg value="${git.revision}"/>
<arg value="${git.base.revision}"/>
</exec>

<property name="files.changeset" value="${changesetfiles}">
<filterchain>
<replaceregexp>
<regexp pattern="\n" replace=" " ignoreCase="true"/>
</replaceregexp>
</filterchain>
</property>

<property name="files.changeset.php" value="${changesetfiles}">
<filterchain>
<linecontainsregexp>
<regexp pattern=".php$"/>
</linecontainsregexp>
<replaceregexp>
<regexp pattern="\n" replace=" " ignoreCase="true"/>
</replaceregexp>
</filterchain>
</property>
</target>
</project>

0 comments on commit fd55818

Please sign in to comment.