| Title: | Utilities for renaming branches on GitHub |
|---|---|
| Description: | The package provides utility functions at the user and organization level for renaming branches on GitHub. The functions are written mainly for modifying batches of either repositories or packages. It uses tools to authenticate and call git from within R. |
| Authors: | Marcel Ramos [aut, cre] (ORCID: <https://orcid.org/0000-0002-3242-0582>) |
| Maintainer: | Marcel Ramos <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 0.99.2 |
| Built: | 2026-05-30 09:11:01 UTC |
| Source: | https://github.com/Bioconductor/BranchRename |
The function will create an 'upstream' remote using
[email protected] as the primary address. If an upstream remote
already exists, it will be validated. The remote name can be changed to the
desired name via the remote argument but it is customarily called the
'upstream' remote.
add_bioc_remote(package_path, remote = "upstream")add_bioc_remote(package_path, remote = "upstream")
package_path |
|
remote |
|
Called for the side effect of creating an 'upstream' remote with the Bioconductor git address for a given package
This function will update a repository's remotes by setting origin to the
GitHub location and upstream to the Bioconductor git server.
fix_bioc_remotes(repo_dir, org = "Bioconductor", is_bioc)fix_bioc_remotes(repo_dir, org = "Bioconductor", is_bioc)
repo_dir |
|
org |
|
is_bioc |
|
Called for the side-effect of adjusting git remotes in the
repo_dir; check them with git remote -v
This function will search through an organizations repositories and identify
packages whose default branches are in the branches argument. This allows
the user to identify which repositories will need to have a devel branch
added.
packages_with_default_branch( version = BiocManager::version(), branches = c("master", "main"), org = "Bioconductor" )packages_with_default_branch( version = BiocManager::version(), branches = c("master", "main"), org = "Bioconductor" )
version |
|
branches |
|
org |
|
The output of this function is used in rename_branch_packages.
A named character vector of default branches whose names correspond to package repositories on GitHub
rename_branch_packages
This function identifies an organization's repositories that are packages
given the current version of Bioconductor (from BiocManager::version())
and identifies which repositories need to have a devel branch added.
It then adds the devel branch using the rename_branch_to_devel function.
It is highly recommended that the user run this on the devel version of
Bioconductor to avoid missing packages that are only in devel.
rename_branch_packages( packages = character(0L), version = BiocManager::version(), old_branches = c("master", "main"), org = "Bioconductor", set_upstream = c("origin/devel", "upstream/devel"), clone = TRUE )rename_branch_packages( packages = character(0L), version = BiocManager::version(), old_branches = c("master", "main"), org = "Bioconductor", set_upstream = c("origin/devel", "upstream/devel"), clone = TRUE )
packages |
|
version |
|
old_branches |
|
org |
|
set_upstream |
|
clone |
|
Note that the clone argument allows the user to clone the repository first
from GitHub via SSH. It is recommended that this be enabled and that the
user running this function can clone packages via SSH and have access to
modifying packages on the GitHub organization.
packages_with_default_branch
This function identifies all repositories within an organization that have
old_branches, i.e., either 'master' or 'main' by default. It then
sets the default branch to devel.
rename_branch_repos( repos = character(0L), old_branches = c("master", "main"), org = "Bioconductor", set_upstream = c("origin/devel", "upstream/devel"), clone = TRUE )rename_branch_repos( repos = character(0L), old_branches = c("master", "main"), org = "Bioconductor", set_upstream = c("origin/devel", "upstream/devel"), clone = TRUE )
repos |
|
old_branches |
|
org |
|
set_upstream |
|
clone |
|
repos_with_default_branch
The function is meant to be run one level up from the local git repository.
It will create the 'devel' branch and push to the origin remote which
should be set to GitHub. Upstream tracking can be configured to either the
origin or upstream remote.
rename_branch_to_devel( package_name, from_branch = "master", org = "Bioconductor", set_upstream = c("origin/devel", "upstream/devel"), clone = FALSE, is_bioc_pkg = TRUE )rename_branch_to_devel( package_name, from_branch = "master", org = "Bioconductor", set_upstream = c("origin/devel", "upstream/devel"), clone = FALSE, is_bioc_pkg = TRUE )
package_name |
|
from_branch |
|
org |
|
set_upstream |
|
clone |
|
is_bioc_pkg |
|
The origin remote is assumed to be GitHub, i.e.,
[email protected]:user/package but this requirement is not checked or
enforced; thus, allowing flexibility in remote origin locations. The
upstream remote is validated against the Bioconductor git repository
address, i.e., [email protected]:packages/package. The local
repository is validated before the devel branch is created.
Called for the side effect of creating a 'devel' branch on the local and remote repositories on GitHub
if (interactive()) { rename_branch_to_devel( package_name = "SummarizedExperiment", org = "Bioconductor", set_upstream = "upstream/devel" ) }if (interactive()) { rename_branch_to_devel( package_name = "SummarizedExperiment", org = "Bioconductor", set_upstream = "upstream/devel" ) }
The function obtains all the repositories within the given organization
(Bioconductor) that match the branches argument.
repos_with_default_branch(branches = c("master", "main"), org = "Bioconductor")repos_with_default_branch(branches = c("master", "main"), org = "Bioconductor")
branches |
|
org |
|
The output of this function is used to rename branches with
rename_branch_repos.
A named character vector of default branches whose names correspond to organization repositories on GitHub
rename_branch_repos
These functions works only after renaming branches on GitHub from master
to devel. It updates local folders so that branches are renamed to devel
locally. It also ensures that the HEAD is pointing to the new remote
location, i.e., origin/devel (see gert::git_remote_info()$head). For
convenience, the singular update_local_repo function will update a
particular local repository on the user's system.
update_local_repos( basedir, org = "Bioconductor", username, new_branch = "devel", set_upstream = "origin/devel" ) update_local_repo( repo_dir, is_bioc, new_branch = "devel", set_upstream = "origin/devel", org = "Bioconductor" )update_local_repos( basedir, org = "Bioconductor", username, new_branch = "devel", set_upstream = "origin/devel" ) update_local_repo( repo_dir, is_bioc, new_branch = "devel", set_upstream = "origin/devel", org = "Bioconductor" )
basedir |
|
org |
|
username |
|
new_branch |
target name of the branch once the move is performed; this name is validated for consistency. |
set_upstream |
|
repo_dir |
|
is_bioc |
|
Note that update_local_repos (plural) queries the GitHub API to
discover repositories whose default branches are set to devel. The
function then matches those repository names with local folder names under
basedir and performs the necessary steps to rename the branch and set the
HEAD to origin/devel. The singular function update_local_repo assumes
that the remote change has been made and will rename the local branch and
update the local repository to match the remote 'HEAD'.