diff --git a/CHANGELOG.md b/CHANGELOG.md index e8560356b2..c1df514feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Add `CITATION.cff` [#361](https://github.com/nf-core/tools/issues/361) - Add Gitpod and Mamba profiles to the pipeline template ([#1673](https://github.com/nf-core/tools/pull/1673)) - Remove call to `getGenomeAttribute` in `main.nf` when running `nf-core create` without iGenomes ([#1670](https://github.com/nf-core/tools/issues/1670)) +- Make `nf-core create` fail if Git default branch name is dev or TEMPLATE ([#1705](https://github.com/nf-core/tools/pull/1705)) ### Linting diff --git a/nf_core/create.py b/nf_core/create.py index 896325fa0c..555f451483 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -2,6 +2,7 @@ """Creates a nf-core pipeline matching the current organization's specification based on a template. """ +import configparser import imghdr import logging import os @@ -490,7 +491,24 @@ def download_pipeline_logo(self, url, img_fn): break def git_init_pipeline(self): - """Initialises the new pipeline as a Git repository and submits first commit.""" + """Initialises the new pipeline as a Git repository and submits first commit. + + Raises: + UserWarning: if Git default branch is set to 'dev' or 'TEMPLATE'. + """ + # Check that the default branch is not dev + try: + default_branch = git.config.GitConfigParser().get_value("init", "defaultBranch") + except configparser.Error: + default_branch = None + log.debug("Could not read init.defaultBranch") + if default_branch == "dev" or default_branch == "TEMPLATE": + raise UserWarning( + f"Your Git defaultBranch is set to '{default_branch}', which is incompatible with nf-core.\n" + "This can be modified with the command [white on grey23] git config --global init.defaultBranch [/]\n" + "Pipeline git repository is not initialised." + ) + # Initialise pipeline log.info("Initialising pipeline git repository") repo = git.Repo.init(self.outdir) repo.git.add(A=True)