Skip to content

Commit

Permalink
Merge remote-tracking branch 'szpak/topic/pushDryRun'
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoberstar committed Feb 8, 2015
2 parents 040d27e + 606ae17 commit 356ba3b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ test {
}

wrapper {
gradleVersion = '2.1'
gradleVersion = '2.2.1'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Oct 19 15:59:24 CDT 2014
#Thu Dec 11 23:51:19 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
10 changes: 10 additions & 0 deletions src/main/groovy/org/ajoberstar/grgit/operation/PushOp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ class PushOp implements Callable<Void> {
*/
boolean force = false

/**
* {@code true} if result of this operation should be just estimation
* of real operation result, no real push is performed.
* {@code false} (the default) if real push to remote repo should be performed.
*
* @since 0.4.1
*/
boolean dryRun = false

PushOp(Repository repo) {
this.repo = repo
}
Expand All @@ -100,6 +109,7 @@ class PushOp implements Callable<Void> {
if (all) { cmd.setPushAll() }
if (tags) { cmd.setPushTags() }
cmd.force = force
cmd.dryRun = dryRun
try {
cmd.call()
return null
Expand Down
19 changes: 19 additions & 0 deletions src/test/groovy/org/ajoberstar/grgit/operation/PushOpSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,23 @@ class PushOpSpec extends MultiGitOpSpec {
GitTestUtil.resolve(localGrgit, 'refs/heads/my-branch') == GitTestUtil.resolve(remoteGrgit, 'refs/heads/other-branch')
!GitTestUtil.tags(remoteGrgit)
}

def 'push in dryRun mode does not push commits'() {
given:
def remoteMasterHead = GitTestUtil.resolve(remoteGrgit, 'refs/heads/master')
when:
localGrgit.push(dryRun: true)
then:
GitTestUtil.resolve(localGrgit, 'refs/heads/master') != GitTestUtil.resolve(remoteGrgit, 'refs/heads/master')
GitTestUtil.resolve(remoteGrgit, 'refs/heads/master') == remoteMasterHead
}

def 'push in dryRun mode does not push tags'() {
given:
def remoteMasterHead = GitTestUtil.resolve(remoteGrgit, 'refs/heads/master')
when:
localGrgit.push(dryRun: true, tags: true)
then:
!GitTestUtil.tags(remoteGrgit)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class StatusOpSpec extends SimpleGitOpSpec {
grgit.status() == new Status(staged: [modified: ['1.txt', '2.txt']])
}

def 'staged new files detected'() {
def 'staged removed files detected'() {
given:
assert repoFile('3.txt').delete()
assert repoFile('0.txt').delete()
Expand Down

0 comments on commit 356ba3b

Please sign in to comment.