... | ... | @@ -463,12 +463,14 @@ problem as long as everyone pushes to the replica. |
|
|
|
|
|
## Branch Name Changes
|
|
|
|
|
|
Changing the name of a default branch both locally and on remotes can be partially automated with the use of [anarcat's branch rename script](https://gitlab.com/anarcat/scripts/-/blob/main/git-branch-rename-remote). This script performs the following tasks:
|
|
|
Changing the name of a default branch both locally and on remotes can
|
|
|
be partially automated with the use of [anarcat's branch rename
|
|
|
script](https://gitlab.com/anarcat/scripts/-/blob/main/git-branch-rename-remote). This script performs the following tasks:
|
|
|
|
|
|
```
|
|
|
# rename the branch locally if not already done
|
|
|
git show-ref refs/heads/master > /dev/null && \
|
|
|
git branch --move master main
|
|
|
git branch --move master main
|
|
|
git fetch origin
|
|
|
# fix HEAD pointer for local remote branch
|
|
|
git symbolic-ref refs/remotes/remote/HEAD refs/remotes/remote/main
|
... | ... | @@ -481,36 +483,49 @@ ssh example.com git symbolic-ref HEAD main |
|
|
git push -d origin master
|
|
|
```
|
|
|
|
|
|
If the `ssh` step fails, it will try to do the equivalent over the GitLab API, that is:
|
|
|
If the `ssh` step fails, it will try to do the equivalent over the
|
|
|
GitLab API, that is:
|
|
|
|
|
|
```
|
|
|
1. unprotect the old branch
|
|
|
2. protect the new branch
|
|
|
3. change the default branch
|
|
|
4. *then* `git push -d` to delete the old branch
|
|
|
```
|
|
|
1. unprotect the old branch
|
|
|
2. protect the new branch
|
|
|
3. change the default branch
|
|
|
4. *then* `git push -d` to delete the old branch
|
|
|
|
|
|
However, there are a few extra steps and considerations to make when changing the name of a heavily used branch.
|
|
|
However, there are a few extra steps and considerations to make when
|
|
|
changing the name of a heavily used branch.
|
|
|
|
|
|
### Modifying open Merge Requests
|
|
|
|
|
|
A merge request that is open against the modified branch may be bricked as a result of deleting the old branch name from the Gitlab remote. To avoid this, after creating and pushing the new branch name, edit each merge request to target the new branch name **before** deleting the old branch.
|
|
|
A merge request that is open against the modified branch may be
|
|
|
bricked as a result of deleting the old branch name from the Gitlab
|
|
|
remote. To avoid this, after creating and pushing the new branch name,
|
|
|
edit each merge request to target the new branch name **before**
|
|
|
deleting the old branch.
|
|
|
|
|
|
### Updating gitolite
|
|
|
|
|
|
Many GitLab repositories are mirrored or maintained manually on gitolite (git-rw.torproject.org) and gitweb (https://git.torproject.org). The `ssh` step for the above automation script will fail for gitolite and these steps need to be done manually by a sysadmin. [Open a TPA ticket](https://gitlab.torproject.org/tpo/tpa/team/-/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) with a list of the gitolite repositories you would like to update and a sysadmin will perform the following magic:
|
|
|
Many GitLab repositories are mirrored or maintained manually on
|
|
|
gitolite (`git-rw.torproject.org`) and [Gitweb](https://gitweb.torproject.org). The `ssh` step for
|
|
|
the above automation script will fail for gitolite and these steps
|
|
|
need to be done manually by a sysadmin. [Open a TPA ticket](https://gitlab.torproject.org/tpo/tpa/team/-/issues/new) with a
|
|
|
list of the gitolite repositories you would like to update and a
|
|
|
sysadmin will perform the following magic:
|
|
|
|
|
|
```
|
|
|
root@cupani:/srv/git.torproject.org/repositories# for repo in [list]; do
|
|
|
> git -C "$repo" symbolic-ref HEAD refs/heads/[new branch name]
|
|
|
> done
|
|
|
```
|
|
|
cd /srv/git.torproject.org/repositories/
|
|
|
for repo in $list; do
|
|
|
git -C "$repo" symbolic-ref HEAD refs/heads/$to_branch
|
|
|
done
|
|
|
|
|
|
This will update gitolite, but it won't update gitweb until the repositories have been pushed to. To udpate gitweb immediately, ask your friendly sysadmin to update gitweb manually.
|
|
|
This will update Gitolite, but it won't update Gitweb until the
|
|
|
repositories have been pushed to. To udpate Gitweb immediately, ask
|
|
|
your friendly sysadmin to run the above command on the Gitweb server
|
|
|
as well.
|
|
|
|
|
|
### Updating Transifex
|
|
|
|
|
|
If your repository relies on Transifex for translations, make sure to update the Transifex config to pull from the new branch. To do so, [open a l10n ticket](https://gitlab.torproject.org/tpo/community/l10n/-/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) with the new branch name changes.
|
|
|
If your repository relies on Transifex for translations, make sure to
|
|
|
update the Transifex config to pull from the new branch. To do so,
|
|
|
[open a l10n ticket](https://gitlab.torproject.org/tpo/community/l10n/-/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) with the new branch name changes.
|
|
|
|
|
|
## Pager playbook
|
|
|
|
... | ... | |