Configuration
The recommended way to configure spr is to run spr init, rather than setting config values manually. You can rerun spr init to update config at any time.
spr uses the following Git configuration values:
| config key | CLI flag | description | default1 | default in spr init2 |
|---|---|---|---|---|
auth.github.token3 | --auth-token4 | The token for accessing GitHub (github.com); for GitHub Enterprise, auth.github.HOST.token | obtained by logging in with GitHub, or entered (GitHub Enterprise) | |
target | --target5 | Where pull requests get merged: forge, repository and branch, e.g. github:owner/repo:master6 | the repository that the origin remote points to, and its default branch | |
branchPrefix | --branch-prefix | String used to prefix autogenerated names of pull request branches | spr/GITHUB_USERNAME/ | |
requireApproval | If true, spr land will refuse to land a pull request that is not accepted | false | not set | |
mergeMethod | How pull requests are merged: squash or merge7 | squash | not set | |
stackingMode | How pull requests of stacked commits are set up: base-branches, chain or github-stack8 | base-branches with squash, chain with merge | not set | |
useCommitTitleForInitialCommit | If true, uses the actual commit title for the initial PR commit message. If false, uses [𝘀𝗽𝗿] initial version. | false | not set | |
sprIds | If true, spr diff and spr patch give every local commit an ID (Spr-Id trailer); otherwise only with --spr-id9 | false | not set |
-
The config keys are all in the
sprsection; for example,spr.mergeMethod. -
Values passed on the command line take precedence over values set in Git configuration.
-
Values are read from Git configuration as if by
git config --get, and thus follow its order of precedence in reading from local and global config files. See the git-config docs for details. -
spr initwrites configured values into.git/configin the local repo. (It must be run inside a Git repo.)
-
Value used by
sprif not set in configuration. ↩ -
Value suggested by
spr initif not previously configured. ↩ -
The token for a forge and host:
auth.github.tokenfor github.com,auth.github.HOST.tokenfor GitHub Enterprise onHOST(e.g.spr.auth.github.ghe.example.com.token; the host in lower case, with the port if it has one). Set it in the repository, or globally for all repositories (git config --global …). Before spr supported other hosts, the token wasgithubAuthToken. spr still reads it as the token for github.com ifauth.github.tokenisn’t set, but it’s deprecated and will be removed in a future version: spr shows a note on how to replace it.spr initreplaces it in the repository’s.git/config. ↩ -
For the forge and host of the target. Be careful using this: your auth token will be in your shell history. The deprecated option
--github-auth-tokenstill works. ↩ -
--targettakes a full target, or a branch name alone for a branch in the repository oftarget. It applies to commits without aSpr-Targettrailer, andspr diffgives commits for other targets thantargetsuch a trailer. See Target Another Branch. The deprecated options--github-repository(owner/repo) and--github-master-branchstill work, overriding the repository or the branch oftarget. ↩ -
The notation is
FORGE:REPOSITORY:BRANCH, where the repository may start with//HOST/for another host than the forge’s public one. For now, spr supports only GitHub (github:), with the repository asowner/repo: on github.com (github:owner/repo:main), or on GitHub Enterprise (github://ghe.example.com/owner/repo:main; see GitHub Enterprise). The branch is everything after the last colon (branch names can’t contain colons), e.g.github:acme/project:release/1.2. Beforetarget, spr had two options,githubRepository(owner/repo) andgithubMasterBranch(default:master). spr still reads them iftargetisn’t set, but they’re deprecated and will be removed in a future version: spr shows a note on how to replace them.spr initreplaces them in the repository’s.git/config(and keeps a branch configured there). ↩ -
spr landsquash-merges pull requests, or merges them with a merge commit. The setting also records the convention of the repository, as pull requests may be merged in the GitHub UI, too. See Choose a Merge Method and Stacking Mode. ↩ -
base-branches: the pull request targets a synthetic base branch created by spr.chain: the pull request targets the pull request branch of the parent commit.github-stack: likechain, and the pull requests are linked as a stack on GitHub (GitHub’s stacked pull requests feature, in public preview). The combination ofmergeMethodmergeandstackingModebase-branchesis not allowed. See Choose a Merge Method and Stacking Mode for the trade-offs. ↩ -
The ID identifies a local commit and its pull request across amends and rebases, like Gerrit’s
Change-Id. It only appears in local commit messages — not in pull requests, nor in the commits that land. The setting only controls whether IDs are added automatically: commits that have an ID keep it either way. See Identify Commits with Spr-Ids. ↩