Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git default branch #1705

Merged
merged 10 commits into from
Jul 29, 2022
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 19 additions & 1 deletion nf_core/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <NAME> [/]\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)
Expand Down