Skip to content

Commit

Permalink
Merge pull request #1705 from mirpedrol/git-default-branch
Browse files Browse the repository at this point in the history
Git default branch
  • Loading branch information
ErikDanielsson authored Jul 29, 2022
2 parents 3c22ebb + 9833007 commit 880d627
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 880d627

Please sign in to comment.