Skip to content

Commit 450bb9f

Browse files
committed
Make the default development branch configurable
Up to now, the `master` branch was the default development branch. And now it's possible to configure it by running the `acquire-repository` command. So, after the configuration, the provided value will be used instead of the `master`. However, the `master` is still a default one. But now, it's possible to set another branch as a default one (for instance, `develop`) and Elegant Git will use it.
1 parent d369463 commit 450bb9f

12 files changed

+32
-6
lines changed

docs/configuration.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if you `acquire-repository`, it proposes defaults that are set by `acquire-git`.
3434
2. setting your email usign `user.email` [`b`]
3535
3. setting a default editor using `core.editor` [`b`]
3636
4. setting protected branches using `elegant-git.protected-branches` [`l`]
37+
5. setting a default development branch using `elegant-git.default-branch` [`l`]
3738

3839
# Level: Standards
3940

@@ -84,9 +85,14 @@ For now, only `gpg` is supported. If you need other tools, please [create a new
8485
The Elegant Git configuration keys:
8586

8687
- `elegant-git.protected-branches` defines the protected branches (if there are multiple values, they
87-
should be separarated with space). By default, `master` branch treats as protected. The "protected"
88+
should be separarated with space). By default, the `master` branch treats as protected. The "protected"
8889
means that Elegant Git commands for a branch state modification (such as `save-work`, `polish-work`,
8990
etc.) are prohibited to work if the current branch is protected. Also, the protected branches cannot
9091
be removed while running Elegant Git commands for serving a repository.
9192
- `elegant-git.acquired` defines whether a user was applied global configuration or not (see
9293
[approach](#approach) for the details).
94+
- `elegant-git.default-branch` defines the name of the default development branch. By default, the `master`
95+
branch treats as the default one. Depending on an Elegant Git command, it can be a source branch to create
96+
a new branch from, a destination branch to rebase work in, a base branch to compare with, a release branch,
97+
and can be used in other ways. In other words, the default development branch is "a golden source" of
98+
modifications (commits) for any manipulation that needs them.

libexec/git-elegant

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ git-verbose-op() {
2828
${processor} "$(git "$@" 2>&1)"
2929
}
3030

31-
DEFAULT_BRANCH="master"
32-
DEFAULT_UPSTREAM_REPOSITORY="origin"
33-
DEFAULT_REMOTE_TRACKING_BRANCH="${DEFAULT_UPSTREAM_REPOSITORY}/${DEFAULT_BRANCH}"
34-
3531
_error-if-empty() {
3632
# _error-if-empty <a value to check> <error message>
3733
if [[ -z "$1" ]]; then

libexec/git-elegant-accept-work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ MESSAGE
6060
local work_branch="__eg"
6161
local changes=${1}
6262
source ${BINS}/plugins/state
63+
source ${BINS}/plugins/configuration-default-branches
6364
if is-there-active-rebase; then
6465
local rb=$(rebasing-branch)
6566
if [[ ${work_branch} == ${rb} ]]; then

libexec/git-elegant-acquire-repository

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ MESSAGE
3232
default() {
3333
source ${BINS}/plugins/configuration
3434
source ${BINS}/plugins/configuration-protected-branches
35+
source ${BINS}/plugins/configuration-default-branches
3536
source ${BINS}/plugins/configuration-acquired
3637
obsolete-configurations-removing --local
3738
basics-configuration --local \
3839
user_name \
3940
user_email \
4041
core_editor \
42+
default_branch \
4143
protected_branches
4244
if ! is-git-acquired ; then
4345
standards-configuration --local \

libexec/git-elegant-deliver-work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ MESSAGE
5858
--deliver-work-logic() {
5959
source ${BINS}/plugins/state
6060
source ${BINS}/plugins/transformation
61+
source ${BINS}/plugins/configuration-default-branches
6162
if is-there-active-rebase; then
6263
git-verbose rebase --continue
6364
else

libexec/git-elegant-polish-work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ MESSAGE
3939
default() {
4040
local current_branch=$(git rev-parse --abbrev-ref HEAD)
4141
source ${BINS}/plugins/configuration-protected-branches
42+
source ${BINS}/plugins/configuration-default-branches
4243
if is-branch-protected ${current_branch}; then
4344
error-box "The protected '${current_branch}' branch history can't be rewritten."
4445
error-text "Please read more on ${__site}."

libexec/git-elegant-prune-repository

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ MESSAGE
4343

4444
default() {
4545
source ${BINS}/plugins/state
46+
source ${BINS}/plugins/configuration-default-branches
4647
git-verbose checkout ${DEFAULT_BRANCH}
4748
if is-there-upstream-for ${DEFAULT_BRANCH}; then
4849
git-verbose fetch --all || info-text "As the remotes can't be fetched, the current local version is used."

libexec/git-elegant-release-work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ MESSAGE
5959
}
6060

6161
--release-work() {
62+
source ${BINS}/plugins/configuration-default-branches
6263
git-verbose checkout ${DEFAULT_BRANCH}
6364
git-verbose pull --tags
6465
source ${BINS}/plugins/state

libexec/git-elegant-show-work

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ modifications, and available stashes.
2222
Approximate commands flow is
2323
\`\`\`bash
2424
==>> git elegant show-work
25-
git log --oneline ${DEFAULT_BRANCH}..@
25+
git log --oneline master..@
2626
git status --short
2727
git stash list
2828
\`\`\`
2929
MESSAGE
3030
}
3131

3232
default(){
33+
source ${BINS}/plugins/configuration-default-branches
3334
local branch=$(git rev-parse --abbrev-ref @)
3435
info-text ">>> Branch refs:"
3536
info-text "local: ${branch}"

libexec/git-elegant-start-work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ MESSAGE
4343

4444
--start-work-logic(){
4545
source ${BINS}/plugins/state
46+
source ${BINS}/plugins/configuration-default-branches
4647
local target=${2:-${DEFAULT_BRANCH}}
4748
git-verbose checkout ${target}
4849
if is-there-upstream-for ${target}; then

0 commit comments

Comments
 (0)