Skip to content
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

Make markdown reporter more diff friendly #326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ import com.github.jk1.license.PomData
import com.github.jk1.license.ProjectData

class InventoryMarkdownReportRenderer extends InventoryReportRenderer {
private Boolean includeTimestamp
private Boolean includeCounter

InventoryMarkdownReportRenderer(String fileName = 'licenses.md', String name = null, File overridesFile = null) {
InventoryMarkdownReportRenderer(String fileName = 'licenses.md', String name = null, File overridesFile = null,
Boolean includeTimestamp = true, Boolean includeCounter = true) {
super(fileName, name, overridesFile)
this.includeTimestamp = includeTimestamp
this.includeCounter = includeCounter
}

@Override
Expand Down Expand Up @@ -68,7 +73,7 @@ class InventoryMarkdownReportRenderer extends InventoryReportRenderer {
output << "\n"
output << "# ${name}\n"
output << "## Dependency License Report\n"
output << "_${new Date().format('yyyy-MM-dd HH:mm:ss z')}_\n"
if (includeTimestamp) output << "_${new Date().format('yyyy-MM-dd HH:mm:ss z')}_\n"
}

protected void printDependency(ModuleData data) {
Expand Down Expand Up @@ -109,7 +114,7 @@ class InventoryMarkdownReportRenderer extends InventoryReportRenderer {
}

protected void printDependencyMetaInformation(ModuleData data) {
output << "**${++counter}** "
if (includeCounter) output << "**${++counter}** "
if (data.group) output << "**Group:** `$data.group` "
if (data.name) output << "**Name:** `$data.name` "
if (data.version) output << "**Version:** `$data.version` "
Expand Down Expand Up @@ -154,7 +159,8 @@ class InventoryMarkdownReportRenderer extends InventoryReportRenderer {

protected printImportedDependency(ImportedModuleData data) {
output << "\n\n"
output << "${++counter}. **${data.name} v${data.version}**\n"
if (includeCounter) output << "${++counter}. "
output << "**${data.name} v${data.version}**\n"
output << sectionLink("Project URL", data.projectUrl, data.projectUrl)
output << sectionLink("License URL", data.license, data.licenseUrl)
output << "\n\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ class InventoryMarkdownReportRendererSpec extends AbstractInventoryReportRendere
def sanitizedOutput = outputFile.text.replaceAll("_[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z0-9-]+_", "DATE")
snapshotter.assertThat(sanitizedOutput).matchesSnapshot()
}

def "check the correct generation of markdown without timestamp and counter"() {
def renderer = new InventoryMarkdownReportRenderer(outputFile.name, "name", overrides, false, false)
when:
renderer.render(projectData)
then:
outputFile.exists()
snapshotter.assertThat(outputFile.text).matchesSnapshot()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# name
## Dependency License Report
## Apache License, Version 2.0

**Group:** `dummy-group` **Name:** `mod1` **Version:** `0.0.1`
> - **Manifest Project URL**: [http://dummy-mani-url](http://dummy-mani-url)
> - **Manifest License**: Apache 2.0 (Not Packaged)
> - **POM Project URL**: [http://dummy-pom-project-url](http://dummy-pom-project-url)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
> - **Embedded license files**: [apache2.license](apache2.license)

**Group:** `dummy-group` **Name:** `mod2` **Version:** `0.0.1`
> - **Project URL**: [https://projecturl](https://projecturl)
> - **License URL**: [http://www.apache.org/licenses/LICENSE-2.0.txt](Apache License, Version 2.0)

**Group:** `dummy-group` **Name:** `mod4` **Version:** `0.0.1`
> - **Manifest Project URL**: [http://dummy-mani-url](http://dummy-mani-url)
> - **Manifest License**: Apache 2.0 (Not Packaged)
> - **POM Project URL**: [http://dummy-pom-project-url](http://dummy-pom-project-url)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
> - **Embedded license files**: [apache2.license](apache2.license)

## MIT License

**Group:** `dummy-group` **Name:** `mod4` **Version:** `0.0.1`
> - **Manifest Project URL**: [http://dummy-mani-url](http://dummy-mani-url)
> - **Manifest License**: Apache 2.0 (Not Packaged)
> - **POM Project URL**: [http://dummy-pom-project-url](http://dummy-pom-project-url)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
> - **Embedded license files**: [apache2.license](apache2.license)

## Unknown

**Group:** `dummy-group` **Name:** `mod3` **Version:** `0.0.1`
> - **POM Project URL**: [http://dummy-pom-project-url](http://dummy-pom-project-url)
> - **POM License**: Unknown

## bundle1




**mod1 vsome-version**
> - **Project URL**: [some-projectUrl](some-projectUrl)
> - **License URL**: [apache-url](Apache 2)




**mod2 vsome-version**
> - **Project URL**: [some-projectUrl](some-projectUrl)
> - **License URL**: [apache-url](Apache 2)