Skip to content

Commit

Permalink
Put recurseSubmodules option in the manifest scope
Browse files Browse the repository at this point in the history
Signed-off-by: Akira Sekiguchi <akira.sekiguchi@dnaform.jp>
  • Loading branch information
Akira Sekiguchi committed Aug 1, 2020
1 parent 82c6fea commit 4d888b1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ Name Description
================== ================
author Project author name (use a comma to separate multiple names).
defaultBranch Git repository default branch (default: ``master``).
recurseSubmodules Turn this flag to ``true`` to pull submodules recursively from the Git repository
description Free text describing the workflow project.
homePage Project home page URL.
mainScript Project main script (default: ``main.nf``).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class CmdClone extends CmdBase implements HubOptions {
@Parameter(names='-r', description = 'Revision to clone - It can be a git branch, tag or revision number')
String revision

@Parameter(names=['-recursive','-recurse-submodules'], description = 'initialize submodules in the clone', arity = 0)
boolean recurse_submodules

@Override
final String getName() { NAME }

Expand All @@ -66,7 +63,7 @@ class CmdClone extends CmdBase implements HubOptions {

manager.checkValidRemoteRepo()
print "Cloning ${manager.project}${revision ? ':'+revision:''} ..."
manager.clone(target, revision, recurse_submodules)
manager.clone(target, revision)
print "\r"
println "${manager.project} cloned to: $target"
}
Expand Down
6 changes: 2 additions & 4 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class CmdPull extends CmdBase implements HubOptions {
@Parameter(names=['-r','-revision'], description = 'Revision of the project to run (either a git branch, tag or commit SHA number)')
String revision

@Parameter(names='-recursive', description = 'control recursive fetching of submodules', arity = 0)
boolean recurse_submodules


@Override
Expand Down Expand Up @@ -73,8 +71,8 @@ class CmdPull extends CmdBase implements HubOptions {
log.info "Checking $it ..."
def manager = new AssetManager(it, this)

def result = manager.download(recurse_submodules, revision)
manager.updateModules(recurse_submodules)
def result = manager.download(revision)
manager.updateModules()

def scriptFile = manager.getScriptFile()
String message = !result ? " done" : " $result"
Expand Down
7 changes: 2 additions & 5 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ class CmdRun extends CmdBase implements HubOptions {
@Parameter(names=['-bucket-dir'], description = 'Remote bucket where intermediate result files are stored')
String bucketDir

@Parameter(names=['-recursive','-recurse-submodules'], description = 'Try to download submodules recursively if those do not exist', arity = 0)
boolean recurse_submodules

/**
* Defines the parameters to be passed to the pipeline script
*/
Expand Down Expand Up @@ -339,15 +336,15 @@ class CmdRun extends CmdBase implements HubOptions {
if( offline )
throw new AbortOperationException("Unknown project `$repo` -- NOTE: automatic download from remote repositories is disabled")
log.info "Pulling $repo ..."
def result = manager.download(recurse_submodules)
def result = manager.download()
if( result )
log.info " $result"
checkForUpdate = false
}
// checkout requested revision
try {
manager.checkout(revision)
manager.updateModules(recurse_submodules)
manager.updateModules()
def scriptFile = manager.getScriptFile()
log.info "Launching `$repo` [$runName] - revision: ${scriptFile.revisionInfo}"
if( checkForUpdate && !offline )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class Manifest {
target.gitmodules
}

boolean getRecurseSubmodules() {
target.recurseSubmodules
}

String getNextflowVersion() {
target.nextflowVersion
}
Expand Down
20 changes: 12 additions & 8 deletions modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ class AssetManager {
* @param revision The revision to download
* @result A message representing the operation result
*/
def download(boolean recurse_submodules = false, String revision=null) {
def download(String revision=null) {
assert project

/*
Expand All @@ -593,7 +593,7 @@ class AssetManager {
clone
.setURI(cloneURL)
.setDirectory(localPath)
.setCloneSubmodules(recurse_submodules)
.setCloneSubmodules(manifest.recurseSubmodules)
.call()

// return status message
Expand Down Expand Up @@ -639,7 +639,9 @@ class AssetManager {
if( provider.hasCredentials() )
pull.setCredentialsProvider( new UsernamePasswordCredentialsProvider(provider.user, provider.password))

pull.setRecurseSubmodules(FetchRecurseSubmodulesMode.YES)
if( manifest.recurseSubmodules ) {
pull.setRecurseSubmodules(FetchRecurseSubmodulesMode.YES)
}
def result = pull.call()
if(!result.isSuccessful())
throw new AbortOperationException("Cannot pull project `$project` -- ${result.toString()}")
Expand All @@ -654,7 +656,7 @@ class AssetManager {
* @param directory The folder when the pipeline will be cloned
* @param revision The revision to be cloned. It can be a branch, tag, or git revision number
*/
void clone(File directory, String revision = null, boolean recurse_submodules) {
void clone(File directory, String revision = null) {

def clone = Git.cloneRepository()
def uri = getGitRepositoryUrl()
Expand All @@ -665,7 +667,7 @@ class AssetManager {

clone.setURI(uri)
clone.setDirectory(directory)
clone.setCloneSubmodules(recurse_submodules)
clone.setCloneSubmodules(manifest.recurseSubmodules)
if( provider.hasCredentials() )
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(provider.user, provider.password))

Expand Down Expand Up @@ -926,7 +928,9 @@ class AssetManager {
if(provider.hasCredentials()) {
fetch.setCredentialsProvider( new UsernamePasswordCredentialsProvider(provider.user, provider.password) )
}
fetch.setRecurseSubmodules(FetchRecurseSubmodulesMode.YES)
if( manifest.recurseSubmodules ) {
fetch.setRecurseSubmodules(FetchRecurseSubmodulesMode.YES)
}
fetch.call()
git.checkout()
.setCreateBranch(true)
Expand All @@ -941,7 +945,7 @@ class AssetManager {

}

void updateModules(boolean recurse_submodules = false) {
void updateModules() {

if( !localPath )
return // nothing to do
Expand All @@ -966,7 +970,7 @@ class AssetManager {
final init = git.submoduleInit()
final update = git.submoduleUpdate()

if (recurse_submodules) {
if( manifest.recurseSubmodules ) {
update.setStrategy(MergeStrategy.RECURSIVE)
}

Expand Down

0 comments on commit 4d888b1

Please sign in to comment.