diff --git a/README.md b/README.md index 84906eb..e4da46a 100644 --- a/README.md +++ b/README.md @@ -69,14 +69,6 @@ prov { List of file patterns to include in the provenance report, from the set of published files. By default, all published files are included. -## Examples - -```bash -nextflow run https://github.com/ORGANIZATION/REPOSITORY_ID -profile docker -nextflow run https://bitbucket.org/ORGANIZATION/REPOSITORY_ID -profile docker -nextflow run https://gitlab.com/PROJECT/REPOSITORY_ID -profile docker -``` - ## Development Run the following commands to build and test the nf-prov Nextflow plugin. Refer to the [nf-hello](https://github.com/nextflow-io/nf-hello) README for additional instructions (_e.g._ for publishing the plugin). diff --git a/plugins/nf-prov/src/main/nextflow/prov/BcoRenderer.groovy b/plugins/nf-prov/src/main/nextflow/prov/BcoRenderer.groovy index 1fa4eae..4b67e3c 100644 --- a/plugins/nf-prov/src/main/nextflow/prov/BcoRenderer.groovy +++ b/plugins/nf-prov/src/main/nextflow/prov/BcoRenderer.groovy @@ -39,58 +39,6 @@ class BcoRenderer implements Renderer { private boolean overwrite - private URL repository - - private String commitId - - private String launchDir - - private String projectDir - - private String workDir - - /** - * Normalize local paths to remove environment-specific directories. - * - * @param path - */ - private String normalizePath(Path path) { - normalizePath(path.toUriString()) - } - - private String normalizePath(String path) { - // replace work directory with relative path - if( path.startsWith(workDir) ) - return path.replace(workDir, 'work') - - // replace project directory with source URL (if applicable) - if( repository && path.startsWith(projectDir) ) - return getProjectSourceUrl(path) - - // replace launch directory with relative path - if( path.startsWith(launchDir) ) - return path.replace(launchDir + '/', '') - - return path - } - - /** - * Get the source URL for a project asset. - * - * @param path - */ - private String getProjectSourceUrl(String path) { - // TODO: add other git providers - if( repository.host == 'github.com' ) - return path.replace(projectDir, "${repository}/tree/${commitId}") - else if( repository.host == 'bitbucket.org' ) - return path.replace(projectDir, "${repository}/src/${commitId}") - else if( repository.host == 'gitlab.com' ) - return path.replace(projectDir, "${repository}/-/tree/${commitId}") - else - return path - } - @Delegate private PathNormalizer normalizer @@ -114,12 +62,6 @@ class BcoRenderer implements Renderer { final manifest = metadata.manifest final nextflowMeta = metadata.nextflow - this.repository = metadata.repository ? new URL(metadata.repository) : null - this.commitId = metadata.commitId - this.projectDir = metadata.projectDir.toUriString() - this.launchDir = metadata.launchDir.toUriString() - this.workDir = metadata.workDir.toUriString() - final dateCreated = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(metadata.start) final authors = (manifest.author ?: '').tokenize(',')*.trim() final nextflowVersion = nextflowMeta.version.toString() diff --git a/plugins/nf-prov/src/main/nextflow/prov/PathNormalizer.groovy b/plugins/nf-prov/src/main/nextflow/prov/PathNormalizer.groovy index aa3186e..f0dc26f 100644 --- a/plugins/nf-prov/src/main/nextflow/prov/PathNormalizer.groovy +++ b/plugins/nf-prov/src/main/nextflow/prov/PathNormalizer.groovy @@ -79,11 +79,16 @@ class PathNormalizer { * @param path */ private String getProjectSourceUrl(String path) { - // TODO: add other git providers - if( repository.host == 'github.com' ) + switch( repository.host ) { + case 'bitbucket.org': + return path.replace(projectDir, "${repository}/src/${commitId}") + case 'github.com': return path.replace(projectDir, "${repository}/tree/${commitId}") - else + case 'gitlab.com': + return path.replace(projectDir, "${repository}/-/tree/${commitId}") + default: return path + } } }