nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.76k stars 630 forks source link

Main branch not recognised when executing an online workflow #3593

Closed marcodelapierre closed 1 month ago

marcodelapierre commented 1 year ago

I have a github repo whose primary branch is called main instead of master, which is becoming increasingly common. Nextflow asks me to specify the branch with -r:

$ nextflow run marcodelapierre/toy-cowsay-nf -profile condawave

N E X T F L O W  ~  version 22.12.0-edge
Pulling marcodelapierre/toy-cowsay-nf ...
 downloaded from https://github.com/marcodelapierre/toy-cowsay-nf.git
Project `marcodelapierre/toy-cowsay-nf` is currently stickied on revision: main -- you need to explicitly specify a revision with the option `-r` in order to use it

All good with -r:

$ nextflow run -r main marcodelapierre/toy-cowsay-nf -profile condawave

N E X T F L O W  ~  version 22.12.0-edge
Launching `https://github.com/marcodelapierre/toy-cowsay-nf` [cranky_hypatia] DSL2 - revision: cd804ac170 [main]
executor >  local (8)
[b7/d27846] process > sayHello (1) [100%] 4 of 4 ✔
[35/cabd24] process > cowSay (4)   [100%] 4 of 4 ✔

I suggest to enable Nextflow to look for both master and main branches.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

marcodelapierre commented 1 year ago

pinging this one back as I think it should be discussed - should be a quick fix, if approved for action

@pditommaso @bentsherman @jordeu

bentsherman commented 1 year ago

Basically the AssetManager should be modified to accept both master and main as "default branch" names: https://github.com/nextflow-io/nextflow/blob/fe5bea992e2c0dd99a2f72388df386975c32c83a/modules/nextflow/src/main/groovy/nextflow/scm/AssetManager.groovy#L911-L915

marcodelapierre commented 1 year ago

is there a way to know what is the default branch of a repo?

jordeu commented 1 year ago

is there a way to know what is the default branch of a repo?

The default branch concept do not exists on Git, it is a provider concept. I know that using Github API you can check which is the default branch.

pditommaso commented 1 year ago

Indeed https://stackoverflow.com/a/16501903/395921.

Very likely it's available also on BitBucket and GitLab

ewels commented 1 month ago

This just came up again, @Biowilko was asking if it was the case. I had totally forgotten about this issue and assured him that master couldn't be hardcoded in the codebase 👀 (then I tried it myself)

We're hoping to move to using main as the default branch name for all @nf-core repos soon, but will need to wait for this to be resolved first.

Is it solved by #4659?

marcodelapierre commented 1 month ago

Hey Phil, yep, at the moment any Nextflow git repo whose default branch is not master should have it explicitly mentioned in the manifest for proper functionality:

manifest {
  ..
  name = 'hello world'
  description = 'Toy pipeline for simple Nextflow tests'
  homePage = ' ... '
  ..
  defaultBranch = 'main'
  ..
}

The most developed open PR to handle multiple git revisions is #5089.
With it, pipelines with non master default branch will not give an error.
However, there is still a corner case caveat (documented in the PR) where the default branch appears duplicated in the list of branches, both as DEFAULT (or similar) and <defaultBranch name>. This happens if the pipeline has previously been called both with no -r/--revision flag AND with -r <defaultBranch name>. These two ways of calling the default branch may point to distinct commits over time; they can be reconciled by updating both to latest.

ewels commented 1 month ago

Possible approach to using git to figure this out here: https://stackoverflow.com/questions/28666357/how-to-get-default-git-branch

ewels commented 1 month ago

https://github.com/nextflow-io/socks now has default branch main, can use this for testing.

pditommaso commented 1 month ago

Smell bad 😆

bentsherman commented 1 month ago

Resolved by #5375