Where does tools pull the default branch from when...
# tools
j
Where does tools pull the default branch from when doing a template sync? Every time I do a template update I have to manually switch a bunch of stuff from
master
to
main
πŸ˜“
m
nextflow.config and git config
j
And
git config
?!!?
OOOOOOOOOOOOH
j
Which nextflow.config? In the
TEMPLATE
branch (where it seems to be set to
master
), or in the branch where I run
pipelines sync
(where it is set to main)?
m
oh, actually just git... i thought we also checked nextflow config...
j
My git config has:
Copy code
init.defaultbranch=main
m
also the local one?
j
Copy code
str(git.config.GitConfigParser().get_value("init", "defaultBranch")) or "master"
Should that read
defaultbranch
? Or is my git config wrong here
m
j
Maybe it's just how it displays because setting
defaultBranch
still displays as
defaultbranch
in
git config list
j
Ok I don't get it
j
repo
.git/config
has:
Copy code
[init]
	defaultBranch = main
m
if you run
nf-core p create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface"
what is the default branch in that new pipeline?
j
How do I set the new branch on an existing pipeline exactly?
j
master
j
Context: I have a similar issue with Jim where GitHub linting conflicts with local linting for the 'files not unchanged' check. E.g. I believe default branch is
main
but locally linting wants to see
master
j
OK, I think I found the problem
If I clone a brand new copy of the repo, there is no
defaultBranch
set in the local
.git/config
file
πŸ‘ 1
Despite this being the setting on the GH repo
j
My local clone of #C062H82UCRG also does not have that either
j
So it looks like if you do a template sync locally, it might never respect the GH repo settings, and instead default to either what you have set globally on your local machine, or potentially overwritten in the local repo config?
πŸ‘ 1
Maybe for whatever reason, this does not happen with the automated PR sync that we are not using for our (non-nf-core) pipelines
m
can you rerun the sync command with
nf-core --verbose p sync
and grep for
Could not read init.defaultBranch
because then we fall back to
master
j
I don't see that anywhere in the output
m
and if you just grep for defaultBranch?
j
that's what I did
grep -i defaultBranch ../out
Apparently I have this set globally automatically by my git installation:
Copy code
file:/Library/Developer/CommandLineTools/usr/share/git-core/gitconfig   init.defaultbranch=main
When I run
git init
in a blank directory, I get a
main
m
yep, I think the problem is that it is not in the local git config. i am going through the gitpython docs atm
j
But even setting it in the local repo config doesn't fix the issue:
Copy code
git config set init.defaultBranch main

nf-core --verbose p sync &> ../out
Gives a TEMPLATE branch with
Copy code
defaultBranch   = 'master'
in the nextflow.config file
Regardless, surely it would make more sense for this to reflect a pipeline-specific variable (either from
nextflow.config
or
.nf-core.yml
) rather than trying to pull this from the user's local git config? Because that might conflict with what the pipeline is actually using
m
nextflow.config didn't have that option until recently πŸ™‚
but yes, i agree that we should fix that
πŸ‘ 1
j
https://github.com/nf-core/tools/issues/3423 Oh, someone else has had the same problem
m
j
Will this set the defaultBranch based on the current branch's defaultBranch setting in
nextflow.config
?
m
yes
πŸ‘ 1
or to be more precise to the sync target branch (usually
dev
)
m
Isn’t there a
.nf-core.yml
setting for this ? I remember facing the
master
vs
main
issue when upgrading from template v2.4, and I think my workaround for this (+ all the other changes that had come up in nf-core) was to create a
.nf-core.yml
file with a key somewhere that essentially declared
main
as the default branch.