Change several branches in the same repo
Created by: malomarrec
User problem
Some customers use long-lived branches to define versions or releases. A use case for batch changes is to update each of those branches, for example bumping up dependency versions or changing boilerplate code.
Example
repo
: implements a function foo
dependent-repo
has:
- branch:
release1
importsrepo
and usesfoo
- branch:
release2
importsrepo
and usesfoo
- branch:
release3
importsrepo
and usesfoo
Use case: foo
gets deprecated, and needs to be replaced by foo2
in all releases in dependent-repo
. Each branch is managed by a different team, so there needs to be one changeset per branch.
Current state
- This is not supported today.
- Batch Changes has most of the utilities to define such changes, including batch changes creating several branches and changeset in the same repo and templating to define unique branch names
- Batch Changes already supports changing a specific branch
- Batch Changes does not support changing multiple branches from the same repo
For example, this will only create a changeset on release-2
:
name: multiple-branches
description: Creating changesets on multiple branches does not work
on:
- repository: github.com/malomarrec/batch-change-testing-2
branch: release-1
- repository: github.com/malomarrec/batch-change-testing-2
branch: release-2
steps:
- run: touch hello-world.yml; cat release.yml
container: alpine:3
outputs:
v:
value: ${{step.stdout}}
format: yaml
changesetTemplate:
title: Multiple branches in the same repo
body: Hello from the other siiiiiiiiiide
branch: add-hw-${{outputs.v.release}}
published: true
commit:
message: Hello, it's me.
Impacted customer
Feedback surfaced by: https://github.com/sourcegraph/accounts/issues/544
Proposal
Explicit repository: statements override repositoriesMatchingQuery
.
In the event multiple repository statements are defined with the same repo, only the last one is used. To support multiple branches, the branch:
field can be a string or a list, and can also be named branches.
Examples
- List out branches that I want to modify in a given repository
on:
- repository: github.com/sourcegraph/automation-testing
branches: [release-1, release-2]
Only returns the release-1
, release-2
branches.
- List out branches that I want to modify in a given repository, and mix and match with a query
on:
- repositoriesMatchingQuery: file:README.md
- repository: github.com/sourcegraph/automation-testing
branches: [release-1, release-2]
If the query returns the main branch of sourcegraph/automation-testing, it is overridden by the set of branches named explicitly.
Out of scope
It would be great to modify all the branches in the list of repositories. It's out of scope for now, we might want to introduce a branchesMatchingQuery
on:
- repositoriesMatchingQuery: repo:github\.com/sourcegraph/* rev:*refs/heads/dev* foo
- repositoriesMatchingQuery: repo:github\.com/sourcegraph/* rev:*refs/heads/release-1* foo
- repositoriesMatchingQuery: repo:github\.com/sourcegraph/* rev:*refs/heads/release-2*