Skip to content

added gitlab public repo support #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Support for gitlab public repo #13

## [1.0.0] - 2020-01-09

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/diffplug/blowdryer/BlowdryerSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public void github(String repoOrg, GitAnchorType anchorType, String anchor) {
Blowdryer.setResourcePlugin(resource -> root + resource);
}

/** Sets the source where we will grab these scripts. */
public void gitlab(String repoOrg, GitAnchorType anchorType, String anchor) {
assertNoLeadingOrTrailingSlash(repoOrg);
assertNoLeadingOrTrailingSlash(anchor);
String root = "https://gitlab.com/" + repoOrg + "/-/raw/" + anchor + "/" + repoSubfolder + "/";
Blowdryer.setResourcePlugin(resource -> root + resource);
}

/** Sets the mapping from `file(String)` to `immutableUrl(String)`. */
public void experimental(Closure<String> function) {
experimental(function::call);
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/com/diffplug/blowdryer/BlowdryerPluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ private void settingsGithub(String tag, String... extra) throws IOException {
Arrays.stream(extra).collect(Collectors.joining("\n")));
}

private void settingsGitlab(String tag, String... extra) throws IOException {
write("settings.gradle",
"plugins { id 'com.diffplug.blowdryerSetup' }",
"blowdryerSetup { gitlab('vgropp/blowdryer-test', 'tag', '" + tag + "') }",
Arrays.stream(extra).collect(Collectors.joining("\n")));
}


@Test
public void githubTag() throws IOException {
settingsGithub("test/2/a");
Expand All @@ -56,6 +64,32 @@ public void githubTag() throws IOException {
gradleRunner().buildAndFail();
}

@Test
public void gitlabTag() throws IOException {
settingsGitlab("test/2/a");
write("build.gradle",
"apply plugin: 'com.diffplug.blowdryer'",
"assert 干.file('sample').text == 'a'",
"assert 干.prop('sample', 'name') == 'test'",
"assert 干.prop('sample', 'ver_spotless') == '1.2.0'");
gradleRunner().build();

settingsGitlab("test/2/b");
write("build.gradle",
"apply plugin: 'com.diffplug.blowdryer'",
"assert 干.file('sample').text == 'b'",
"assert 干.prop('sample', 'name') == 'testB'",
"assert 干.prop('sample', 'group') == 'com.diffplug.gradleB'");
gradleRunner().build();

// double-check that failures do fail
settingsGitlab("test/2/b");
write("build.gradle",
"plugins { id 'com.diffplug.blowdryer' }",
"assert Blowdryer.file('sample').text == 'a'");
gradleRunner().buildAndFail();
}

@Test
public void devLocal() throws IOException {
write("../blowdryer-script/src/main/resources/sample", "c");
Expand Down