You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It sounds like a good idea. Here are 2 complementing ideas to your proposal:
we try detect the default branch name.
def default_git_branch
default_branch = Fastlane::Actions.git_remote_branch_name(nil)
default_branch = default_branch.split("\n")[0] if default_branch
default_branch ||= "main"
end
or
def default_git_branch
begin
first_remote = Fastlane::Actions.sh("git remote | head -1", log: false).chomp
default_branch = Fastlane::Actions.git_remote_branch_name(first_remote)
rescue => e
end
default_branch ||= "main"
end
Also I am using here "main" as default branch. Any reason we should stick to master? We will eventually have to change, right?
Side note: I wish the git_remote_branch_name method was fixed to only return the head of the first remote. We could maybe add a fix for that first. It doesn't really make sense to return a "master\nmaster" if you have 2 remotes with master as default branch. It would also make this code simpler, something like
def default_git_branch
default_branch = Fastlane::Actions.git_remote_branch_name(nil)
default_branch ||= "main"
end
if we really want to ask the user, we could combine asking the user and identifying the default_branch using the above code as first default choice.
Feel free to start your PR, consider using one of the 2 options above.
New Issue Checklist
Issue Description
After setting up a new app recently with
fastlane match
I noticed the default Matchfile generate assumes GitHub's default branch to bemaster
, notmain
.main
is now the default for all new GitHub repositories - see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch and this caused a small amount of reconfiguration work.I'd suggest we should now be prompting for a default branch name on
match init
, and fallback tomaster
if none is provided.If there's agreement, happy to PR that.
Command executed
fastlane match init
Complete output when running fastlane, including the stack trace and command used
Environment
The text was updated successfully, but these errors were encountered: