dependabot-core icon indicating copy to clipboard operation
dependabot-core copied to clipboard

Customizable BranchNamer prefix

Open rafspiny opened this issue 4 years ago • 3 comments

I would like the BranchNamer prefix argument passed from the PullRequestCreator to be customizable. Perhaps through a ENV variable.

Relevant constructor: https://github.com/dependabot/dependabot-core/blob/92533d45e69aab0aa5b3bccf90b7668ed678b476/common/lib/dependabot/pull_request_creator.rb#L33

There were similar issues. Like this one:

  • https://github.com/dependabot/dependabot-core/issues/2136

In this one, it is being asked to customize the prefix and its format. In my case there are rules about the prefix my gut feeling is that this is a common scenario. For instance, this the only available values could be: (feature\/*|hotfix\/*|master|production|release\/*) Plus, in my use case there is a limitation on the length of the branch name. This could be handled easily if the prefix is customizable.

I am no ruby expert, but I can prepare a PR if the idea sounds reasonable to you.

rafspiny avatar Aug 18 '20 15:08 rafspiny

Another GitHub customer, David Stanley [email protected] from Webflow, would like this feature as well. Here's what he wrote over email

We'd like to take advantage of the dependabot feature, but the branch names it automatically creates aren't valid for us. We use branch names to tag docker containers and the forward slash "/" is an invalid character for those purposes. Can we somehow configure the branch naming convention/pattern?

Dependabot opened a pull request with "dependabot/npm_and_yarn/apollo-server-express-2.14.2" as the branch name. We use that branch name to tag containers and those forward slashes in the branch name are triggering a warning with our CI system. Can we configure the pattern that Dependabot uses? That pull request and branch name could instead be "dependabot--npm_and_yarn--apollo-server-express-2.14.2" or something like that?

xrvk avatar Aug 20 '20 23:08 xrvk

@xrvk you can just add separator config to your dependabot.yml

pull-request-branch-name:
      separator: "-"

https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#pull-request-branch-nameseparator

ritaly avatar Feb 04 '21 15:02 ritaly

is there a way to change the . in the branch name as well?

We have ephemeral environments that essentially deploy to a url based on the branch name. The issue is that the . in the branch name i.e dependabot-npm_and_yarn-client-lodash-es-4.17.21 has dots in it that means that our TLS certificates are no longer valid for e.g. dependabot-npm_and_yarn-client-lodash-es-4.17.21.example.com. We can of course use some workaround to rename these in the deployment process but we also use Github Actions Environments and you are not able to update the reference other than what Github provides we currently use the following:

    environment:
      name: ${{ github.head_ref }}
      url: https://${{ github.head_ref }}.example.com

Here we cannot use any string manipulation (we tried with outputs from other jobs etc)

our current workaround is to manually click on the view deployment button and then update the url in the browser which Im sure you can imagine leads to a lot of confusion :laughing:

Spazzy757 avatar Sep 23 '21 08:09 Spazzy757

We have a requirement where our CI setup expects a particular prefix on the branch name to run and deploy the change correctly. It would be of great benefit the branch name prefix option was available to be customised.

harshalpatel06 avatar Sep 23 '22 11:09 harshalpatel06

This seems like a duplicate of https://github.com/dependabot/dependabot-core/issues/396, so closing in favor of that.

Also related:

  • https://github.com/dependabot/dependabot-core/issues/3407
  • https://github.com/dependabot/dependabot-core/issues/4940#issuecomment-1238721997

jeffwidman avatar Nov 24 '22 01:11 jeffwidman