Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,8 @@ The `pull` command downloads a pipeline from a Git-hosting platform into the glo
: Update all downloaded projects.

`-d, -deep`
: :::{deprecated} 25.11.X-edge
:::
: Create a shallow clone of the specified depth.

`-h, -help`
Expand Down Expand Up @@ -1251,6 +1253,8 @@ The `run` command is used to execute a local pipeline script or remote pipeline
: Enable/disable processes caching.

`-d, -deep`
: :::{deprecated} 25.11.X-edge
:::
: Create a shallow clone of the specified depth.

`-disable-jobs-cancellation`
Expand Down
18 changes: 10 additions & 8 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package nextflow.cli

import static nextflow.scm.AssetManager.DEFAULT_REVISION_DIRNAME

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
Expand All @@ -44,7 +42,7 @@ class CmdDrop extends CmdBase {
@Parameter(names=['-r','-revision'], description = 'Revision of the project to drop (either a git branch, tag or commit SHA number)')
String revision

@Parameter(names=['-a','-all-revisions'], description = 'For specified project, drop all revisions')
@Parameter(names=['-a','-all'], description = 'For specified project, drop all pulled commits')
Boolean allRevisions

@Parameter(names='-f', description = 'Delete the repository without taking care of local changes')
Expand All @@ -60,17 +58,21 @@ class CmdDrop extends CmdBase {
List<AssetManager> dropList = []
if ( allRevisions ) {
def revManager = new AssetManager(args[0])
revManager.listRevisions().each { rev ->
if( rev == DEFAULT_REVISION_DIRNAME )
rev = null
if( !revManager.localRootPath.exists() ) {
throw new AbortOperationException("No match found for: ${revManager.getProjectWithRevision()}")
}
revManager.listCommits().each { rev ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try reducing the cyclomatic complexity of this method, splitting in smaller self-describing private methods.

dropList << new AssetManager(args[0]).setRevisionAndLocalPath(args[0], rev)
}
} else {
dropList << new AssetManager(args[0]).setRevisionAndLocalPath(args[0], revision)
}

if ( !dropList ) {
throw new AbortOperationException("No revisions found for specified project: ${args[0]}")
if ( allRevisions && force ) // When removing all revision with 'force' not throw the exception to remove the project folder
log.warn("No revisions found for specified project: ${args[0]}")
else
throw new AbortOperationException("No revisions found for specified project: ${args[0]}")
}

dropList.each { manager ->
Expand All @@ -82,7 +84,6 @@ class CmdDrop extends CmdBase {
manager.close()
if( !manager.localPath.deleteDir() )
throw new AbortOperationException("Unable to delete project `${manager.getProjectWithRevision()}` -- Check access permissions for path: ${manager.localPath}")
manager.pruneRevisionMap(manager.revision)
return
}

Expand All @@ -91,6 +92,7 @@ class CmdDrop extends CmdBase {

if ( allRevisions ) {
def revManager = new AssetManager(args[0])
log.info("Removing directory ${revManager.localRootPath.absolutePath}")
revManager.localRootPath.deleteDir()
}
}
Expand Down
60 changes: 27 additions & 33 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdList.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package nextflow.cli

import static nextflow.scm.AssetManager.DEFAULT_REVISION_DIRNAME

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
Expand Down Expand Up @@ -60,39 +58,35 @@ class CmdList extends CmdBase {
return
}

if( moreDetailed )
detailed = true
if( detailed && allRevisions ) {
all.each{
println(" $it")
def revManager = new AssetManager(it)
revManager.listRevisionsAndCommits().each{ k,v ->
if( k == DEFAULT_REVISION_DIRNAME )
k = '(default)'
if( !moreDetailed )
v = v.substring(0,10)
println(" $v $k") }
}
}
else if( allRevisions ) {
all.each{
println(" $it")
def revManager = new AssetManager(it)
revManager.listRevisions().each{
if( it == DEFAULT_REVISION_DIRNAME )
it = '(default)'
println(" $it")
if( moreDetailed )
detailed = true
if( detailed && allRevisions ) {
all.each {
println(" $it")
def revManager = new AssetManager(it)
revManager.listRevisionsAndCommits().each { k, v ->
if( !moreDetailed )
v = v.substring(0, 10)
println(" $v $k")
}
}
} else if( allRevisions ) {
all.each {
println(" $it")
def revManager = new AssetManager(it)
revManager.listRevisions().each {
println(" $it")
}
}
} else if( allCommits ) {
all.each {
println(" $it")
def revManager = new AssetManager(it)
revManager.listCommits().each { println(" $it") }
}
} else {
all.each { println(" $it") }
}
} else if( allCommits ) {
all.each{
println(" $it")
def revManager = new AssetManager(it)
revManager.listCommits().each{ println(" $it") }
}
} else {
all.each{ println(" $it") }
}
}

}
Comment on lines 61 to 104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, try to make this logic more compact following "Reveal intention" pattern. https://claude.ai/share/32835bb7-8395-431e-a73f-53797de9aaf6

7 changes: 0 additions & 7 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package nextflow.cli

import static nextflow.scm.AssetManager.DEFAULT_REVISION_DIRNAME

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
Expand Down Expand Up @@ -47,9 +45,6 @@ class CmdPull extends CmdBase implements HubOptions {
@Parameter(names=['-r','-revision'], description = 'Revision of the project to pull (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 @@ -81,8 +76,6 @@ class CmdPull extends CmdBase implements HubOptions {
all.each{ proj ->
def revManager = new AssetManager(proj)
revManager.listRevisions().each{ rev ->
if( rev == DEFAULT_REVISION_DIRNAME )
rev = null
list << new AssetManager(proj, this).setRevisionAndLocalPath(proj, rev)
}
}
Expand Down
3 changes: 0 additions & 3 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ 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
Loading
Loading