Skip to content

Commit

Permalink
Merge remote-tracking branch 'Vampire/issue-381' into updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoberstar committed Apr 21, 2023
2 parents 88f1eb9 + 08e3715 commit 2ee722a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 29 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@ plugins {
id 'org.ajoberstar.grgit.service' version '<version>'
}
tasks.register("describe", DescribeTask) {
service = grgitService.service
}
tasks.register("describe", DescribeTask, grgitService.service)
class DescribeTask extends DefaultTask {
@Input
final Property<GrgitService> service
private final Provider<GrgitService> service
@Inject
DoStuffTask(ObjectFactory objectFactory) {
this.service = objectFactory.property(GrgitService.class);
usesService(this.service);
DescribeTask(Provider<GrgitService> service) {
this.service = service
usesService(service)
}
@TaskAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LogOpSpec extends SimpleGitOpSpec {

def 'log with no arguments returns all commits'() {
expect:
grgit.log() == [5, 4, 3, 1, 2, 0].collect(intToCommit)
grgit.log() in [[5, 4, 3, 2, 1, 0], [5, 4, 3, 1, 2, 0]]*.collect(intToCommit)
}

def 'log with max commits returns that number of commits'() {
Expand All @@ -57,7 +57,7 @@ class LogOpSpec extends SimpleGitOpSpec {

def 'log with skip commits does not return the first x commits'() {
expect:
grgit.log(skipCommits:2) == [3, 1, 2, 0].collect(intToCommit)
grgit.log(skipCommits:2) in [[3, 2, 1, 0], [3, 1, 2, 0]]*.collect(intToCommit)
}

def 'log with range returns only the commits in that range'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ plugins {
id 'org.ajoberstar.grgit.service' version '${System.properties['compat.plugin.version']}'
}
tasks.register("doStuff", DoStuffTask.class) {
service = grgitService.service
}
tasks.register("doStuff", DoStuffTask, grgitService.service)
class DoStuffTask extends DefaultTask {
@Input
final Property<GrgitService> service
private final Provider<GrgitService> service
@Inject
DoStuffTask(ObjectFactory objectFactory) {
this.service = objectFactory.property(GrgitService.class);
DoStuffTask(Provider<GrgitService> service) {
this.service = service
usesService(service)
}
@TaskAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package org.ajoberstar.grgit.gradle;

import javax.inject.Inject;

import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;

public class GrgitServiceExtension {
private Property<GrgitService> service;
private final Provider<GrgitService> service;

@Inject
public GrgitServiceExtension(ObjectFactory objectFactory) {
this.service = objectFactory.property(GrgitService.class);
public GrgitServiceExtension(Provider<GrgitService> service) {
this.service = service;
}

public Property<GrgitService> getService() {
public Provider<GrgitService> getService() {
return service;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
public class GrgitServicePlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
GrgitServiceExtension extension = project.getExtensions().create("grgitService", GrgitServiceExtension.class);

Provider<GrgitService> serviceProvider = project.getGradle().getSharedServices().registerIfAbsent("grgit", GrgitService.class, spec -> {
spec.getParameters().getCurrentDirectory().set(project.getLayout().getProjectDirectory());
spec.getParameters().getInitIfNotExists().set(false);
spec.getMaxParallelUsages().set(1);
});

extension.getService().set(serviceProvider);
project.getExtensions().create("grgitService", GrgitServiceExtension.class, serviceProvider);
}
}

0 comments on commit 2ee722a

Please sign in to comment.