Skip to content

Commit

Permalink
Use repository URL instead of Git clone URL
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Sep 5, 2020
1 parent ce42792 commit 75a04d9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 43 deletions.
Expand Up @@ -389,7 +389,7 @@ class AssetManager {

def result = new ScriptFile(getMainScriptFile())
result.revisionInfo = getCurrentRevisionAndName()
result.repository = getGitConfigRemoteUrl()
result.repository = getRepositoryUrl()
result.localPath = localPath.toPath()
result.projectName = project

Expand Down
Expand Up @@ -441,17 +441,20 @@ class AssetManagerTest extends Specification {
dir.resolve('.git/config').text = GIT_CONFIG_TEXT

when:
def manager = new AssetManager()
def p = Mock(RepositoryProvider) { getRepositoryUrl() >> 'https://github.com/nextflow-io/nextflow' }
and:
def manager = new AssetManager(provider: p)
.setLocalPath(dir.toFile())
.setProject('nextflow-io/nextflow')
and:
def script = manager.getScriptFile()
then:
script.localPath == dir
script.commitId == commit.name()
script.revision == 'master'
script.parent == dir
script.text == "println 'Hello world'"
script.repository == 'https://github.com/nextflow-io/nextflow.git'
script.repository == 'https://github.com/nextflow-io/nextflow'
script.projectName == 'nextflow-io/nextflow'
}

Expand Down
Expand Up @@ -17,19 +17,17 @@

package nextflow.script

import java.nio.file.Files

import java.nio.file.Paths
import java.time.OffsetDateTime

import nextflow.Const
import nextflow.Session
import nextflow.scm.AssetManager
import nextflow.trace.TraceRecord
import nextflow.trace.WorkflowStats
import nextflow.trace.WorkflowStatsObserver
import nextflow.util.Duration
import nextflow.util.VersionNumber
import org.eclipse.jgit.api.Git
import spock.lang.Specification
import test.TestHelper
/**
Expand All @@ -42,37 +40,18 @@ class WorkflowMetadataTest extends Specification {

given:
final begin = OffsetDateTime.now()
def dir = Files.createTempDirectory('test')
/*
* create the github repository
*/
dir.resolve('main.nf').text = "println 'Hello world'"
dir.resolve('nextflow.config').text = 'manifest { }'

def init = Git.init()
def repo = init.setDirectory( dir.toFile() ).call()
repo.add().addFilepattern('.').call()
def commit = repo.commit().setAll(true).setMessage('First commit').call()
repo.close()

// append fake remote data
dir.resolve('.git/config') << '''
[remote "origin"]
url = https://github.com/nextflow-io/rnaseq-nf.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
'''
.stripIndent()

/*
* create ScriptFile object
*/
def manager = new AssetManager()
.setLocalPath(dir.toFile())
.setProject('nextflow-io/rnaseq-nf')
def script = manager.getScriptFile()
def localDir = Paths.get('/local/dir')
def mainFile = Paths.get('/some/path/main.nf')
def script = Mock(ScriptFile) {
getScriptId() >> '0e44b16bdeb8ef9f4d8aadcf520e717d'
getMain() >> mainFile
getRepository() >> 'https://github.com/nextflow-io/rnaseq-nf'
getCommitId() >> '1112223344455aaabbbccc'
getRevision() >> 'master'
getLocalPath() >> localDir
getProjectName() >> 'nextflow-io/rnaseq-nf'
}

/*
* config file onComplete handler
Expand All @@ -92,13 +71,13 @@ class WorkflowMetadataTest extends Specification {
session.binding.setVariable('workflow',metadata)
then:
metadata.scriptId == '0e44b16bdeb8ef9f4d8aadcf520e717d'
metadata.scriptFile == manager.scriptFile.main
metadata.scriptFile == mainFile
metadata.scriptName == 'main.nf'
metadata.repository == 'https://github.com/nextflow-io/rnaseq-nf.git'
metadata.commitId == commit.name()
metadata.repository == 'https://github.com/nextflow-io/rnaseq-nf'
metadata.commitId == '1112223344455aaabbbccc'
metadata.revision == 'master'
metadata.container == 'busybox/latest'
metadata.projectDir == dir
metadata.projectDir == localDir
metadata.projectName == 'nextflow-io/rnaseq-nf'
metadata.start >= begin
metadata.start <= OffsetDateTime.now()
Expand Down Expand Up @@ -133,8 +112,6 @@ class WorkflowMetadataTest extends Specification {
then:
metadata.profile == 'foo_profile'

cleanup:
dir?.deleteDir()
}

def foo_test_method() {
Expand Down
2 changes: 1 addition & 1 deletion tests/checks/workflow-oncomplete.nf/.checks
Expand Up @@ -42,7 +42,7 @@ $NXF_CMD run nextflow-io/hello -name third --command hola > stdout
[[ `grep -c 'DONE' stdout` == 1 ]] || false
[[ `grep -c 'command: hola' stdout` == 1 ]] || false
[[ `grep -c 'revision: master' stdout` == 1 ]] || false
[[ `grep -c 'repository: https://github.com/nextflow-io/hello.git' stdout` == 1 ]] || false
[[ `grep -c 'repository: https://github.com/nextflow-io/hello' stdout` == 1 ]] || false
[[ `grep -c 'success: true' stdout` == 1 ]] || false
[[ `grep -c 'exitStatus: 0' stdout` == 1 ]] || false
[[ `grep -c 'runName: third' stdout` == 1 ]] || false

0 comments on commit 75a04d9

Please sign in to comment.