Skip to content

Commit

Permalink
Add clone deep option
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Apr 22, 2023
1 parent a0e501b commit b44b645
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ please refer to the ``nextflow pull`` command.
+---------------------------+------------+--------------------------------------------------------------------------------+
| Name, shorthand (if any) | Default | Description |
+===========================+============+================================================================================+
| -d, -deep | | Create a shallow clone of the specified depth. |
+---------------------------+------------+--------------------------------------------------------------------------------+
| -help, -h | false | Print the command usage. |
+---------------------------+------------+--------------------------------------------------------------------------------+
| -hub | github | Service hub where the project is hosted. Options: ``gitlab`` or ``bitbucket`` |
Expand Down Expand Up @@ -1045,6 +1047,8 @@ and modifies it accordingly. For downloading a pipeline into a local directory,
| Name, shorthand (if any) | Default | Description |
+===========================+============+================================================================================+
| -all | false | Update all downloaded projects. |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -d, -deep | | Create a shallow clone of the specified depth. |
+---------------------------+------------+--------------------------------------------------------------------------------+
| -help, -h | false | Print the command usage. |
+---------------------------+------------+--------------------------------------------------------------------------------+
Expand Down Expand Up @@ -1115,6 +1119,8 @@ facilitates rapid iterations, inspections of any pipeline as well as debugging.
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -cache | | Enable/disable processes caching. |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -deep | | Create a shallow clone of the specified depth. |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -disable-jobs-cancellation| | Prevent the cancellation of child jobs on execution termination |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -dsl1 | false | Execute the workflow using DSL1 syntax. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ 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=['-d','-deep'], description = 'Create a shallow clone of the specified depth')
Integer deep

@Override
final String getName() { NAME }

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

manager.checkValidRemoteRepo()
print "Cloning ${manager.project}${revision ? ':'+revision:''} ..."
manager.clone(target, revision)
manager.clone(target, revision, deep)
print "\r"
println "${manager.project} cloned to: $target"
}
Expand Down
5 changes: 3 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ 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=['-d','-deep'], description = 'Create a shallow clone of the specified depth')
Integer deep

@Override
final String getName() { NAME }
Expand Down Expand Up @@ -75,7 +76,7 @@ class CmdPull extends CmdBase implements HubOptions {
log.info "Checking $it ..."
def manager = new AssetManager(it, this)

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

def scriptFile = manager.getScriptFile()
Expand Down
5 changes: 4 additions & 1 deletion modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ class CmdRun 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=['-d','-deep'], description = 'Create a shallow clone of the specified depth')
Integer deep

@Parameter(names=['-latest'], description = 'Pull latest changes before run')
boolean latest

Expand Down Expand Up @@ -522,7 +525,7 @@ 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(revision)
def result = manager.download(revision,deep)
if( result )
log.info " $result"
checkForUpdate = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class AssetManager {
* @param revision The revision to download
* @result A message representing the operation result
*/
String download(String revision=null) {
String download(String revision=null, Integer deep=null) {
assert project

/*
Expand All @@ -594,9 +594,10 @@ class AssetManager {
clone
.setURI(cloneURL)
.setDirectory(localPath)
.setDepth(1)
.setCloneSubmodules(manifest.recurseSubmodules)
.call()
if( deep )
clone.setDepth(deep)
clone.call()

if( revision ) {
// use an explicit checkout command *after* the clone instead of cloning a specific branch
Expand Down Expand Up @@ -664,7 +665,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) {
void clone(File directory, String revision = null, Integer deep=null) {

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

if( revision )
clone.setBranch(revision)

if( deep )
clone.setDepth(deep)
clone.call()
}

Expand Down

0 comments on commit b44b645

Please sign in to comment.