Skip to content

Commit

Permalink
Remove unused imports and cleanup code (wpilibsuite#25)
Browse files Browse the repository at this point in the history
* Remove unused imports and cleanup code

* Remove public modifier from tests
  • Loading branch information
AustinShalit authored May 8, 2022
1 parent f70e7a8 commit 05d0234
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ package edu.wpi.first.wpilib.versioning
import groovy.transform.CompileStatic
import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Tag
import org.ajoberstar.grgit.operation.OpenOp
import org.gradle.api.Project

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.regex.Pattern

@CompileStatic
Expand Down Expand Up @@ -99,6 +96,7 @@ class GitVersionProvider implements WPILibVersionProvider {
if (describeTag != null) {
String commitId = describeTag.commit.id


// Find all tags matching commit
// Sort by date
Tag newestTag = tags.findAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public WPILibVersioningPluginExtension(Project project, WPILibVersionProvider ve

LocalDateTime.now();
time.set(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
version.set(project.provider(() -> {
return versionProvider.getVersion(this, project, this.useAllTags);
}));
version.set(project.provider(() -> versionProvider.getVersion(this, project, this.useAllTags)));
}

public Property<String> getTime() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package edu.wpi.first.wpilib.versioning

import org.ajoberstar.grgit.Grgit
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Before
import org.junit.Rule
Expand All @@ -29,14 +27,14 @@ class WPILibVersioningPluginTests {
}

@Test
public void 'Applying plugin creates extension'() {
void 'Applying plugin creates extension'() {
def project = createProjectInstance()
project.evaluate()
assertTrue(project.extensions.getByName('wpilibVersioning') instanceof WPILibVersioningPluginExtension)
}

@Test
public void 'Version Regex Works'() {
void 'Version Regex Works'() {
verifyRegex('1', '.0.0')
verifyRegex('1', '.0.0', 'beta-1')
verifyRegex('1', '.0.0', 'rc-1')
Expand All @@ -48,56 +46,56 @@ class WPILibVersioningPluginTests {
}

@Test
public void 'Retrieves Correct Version 1_0_0 official'() {
void 'Retrieves Correct Version 1_0_0 official'() {
verifyProjectVersion('v1.0.0', null, true, "1.0.0")
}

@Test
public void 'Retrieves Correct Version 1_0_0 dev'() {
void 'Retrieves Correct Version 1_0_0 dev'() {
verifyProjectVersion('v1.0.0', null, false, '1.0.0')
}

@Test
public void 'Retrieves Correct Version 1_0_0-alpha-1 official'() {
void 'Retrieves Correct Version 1_0_0-alpha-1 official'() {
verifyProjectVersion('v1.0.0-alpha-1', null, true, "1.0.0-alpha-1")
}

@Test
public void 'Retrieves Correct Version 1_0_0-alpha-1 dev'() {
void 'Retrieves Correct Version 1_0_0-alpha-1 dev'() {
verifyProjectVersion('v1.0.0-alpha-1', null, false, "1.0.0-alpha-1")
}


@Test
public void 'Retrieves Correct Version 1_0_0-beta-1 official'() {
void 'Retrieves Correct Version 1_0_0-beta-1 official'() {
verifyProjectVersion('v1.0.0-beta-1', null, true, "1.0.0-beta-1")
}

@Test
public void 'Retrieves Correct Version 1_0_0-beta-1 dev'() {
void 'Retrieves Correct Version 1_0_0-beta-1 dev'() {
verifyProjectVersion('v1.0.0-beta-1', null, false, "1.0.0-beta-1")
}

@Test
public void 'Retrieves Correct Version 1_0_0-rc-1 official'() {
void 'Retrieves Correct Version 1_0_0-rc-1 official'() {
verifyProjectVersion('v1.0.0-rc-1', null, true, "1.0.0-rc-1")
}

@Test
public void 'Retrieves Correct Version 1_0_0-rc-1 dev'() {
void 'Retrieves Correct Version 1_0_0-rc-1 dev'() {
verifyProjectVersion('v1.0.0-rc-1', null, false, "1.0.0-rc-1")
}

@Test
public void 'Retrieves Correct Version 1_0_0 dev dirty'() {
void 'Retrieves Correct Version 1_0_0 dev dirty'() {
verifyProjectVersion('v1.0.0', null, false, "1.0.0-dirty",
{ project, git ->
new File(project.rootDir, "temp").createNewFile()
})
}

@Test
public void 'Retrieves Correct Version 1_0_0 dev commits'() {
void 'Retrieves Correct Version 1_0_0 dev commits'() {
def ogit
verifyProjectVersion('v1.0.0', null, false, "1.0.0-1-g${-> ogit.log().get(0).getAbbreviatedId()}",
{ project, git ->
Expand All @@ -109,7 +107,7 @@ class WPILibVersioningPluginTests {
}

@Test
public void 'Retrieves Correct Version 1_0_0 dev commits dirty'() {
void 'Retrieves Correct Version 1_0_0 dev commits dirty'() {
def ogit
verifyProjectVersion('v1.0.0', null, false, "1.0.0-1-g${->ogit.log().get(0).getAbbreviatedId()}-dirty",
{ project, git ->
Expand All @@ -123,7 +121,7 @@ class WPILibVersioningPluginTests {
}

@Test
public void 'Retrieves Correct Version 1_424242_0_0 dev localBuild'() {
void 'Retrieves Correct Version 1_424242_0_0 dev localBuild'() {
verifyProjectVersion('v1.0.0-rc-1', '20160803132333', false, '1.424242.0.0-rc-1-20160803132333',
null, true)
}
Expand Down

0 comments on commit 05d0234

Please sign in to comment.