-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-flux-init
88 lines (67 loc) · 3 KB
/
git-flux-init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
cmd_usage_default() {
printf "%s" "[-h]"
}
cmd_long_usage_default() {
printf "%s" "\
$(f_heading "init")
configure the git-flux environment with an interactive survey.
here are the details you need to fill in:
$(f_list_item \
"$(f_fg_blue "feature prefix")" \
"a prefix for feature branch names, defaults to $(f_code "feature/").
for example, $(f_code "foo/") will result in feature branch names like $(f_code "foo/my_awesome_feature"), \
and $(f_code "feature/foo/") will generate names like $(f_code "feature/foo/my_awesome_feature").")
$(f_list_item \
"$(f_fg_yellow "team prefix")" \
"a prefix for team branch names, defaults to $(f_code "team/").")
$(f_list_item \
"$(f_fg_green "release candidate prefix")" \
"a prefix for release candidate branch names, defaults to $(f_code "rc/").")
$(f_list_item \
"$(f_fg_red "hot-fix prefix")" \
"a prefix for hot-fix branch names, defaults to $(f_code "hf/").")
$(f_list_item \
"$(f_fg_magenta "integration branch")" \
"the long-lived integration branch name, defaults to $(f_code "integration").
this branch serves as the base to all team branches, and will be created if not already exists.")
"
}
cmd_default() {
local feature_prefix
local team_prefix
local release_candidate_prefix
local hot_fix_prefix
local integration_branch
local feature_prefix_suggestion
local team_prefix_suggestion
local rc_prefix_suggestion
local hf_prefix_suggestion
local integration_branch_suggestion
local prefix_delimiter="/"
io_log; io_log_banner "git-flux initializer"; io_log
git_config_set "initialized" false
feature_prefix_suggestion="$(git_config_get "prefix.feature")"
team_prefix_suggestion="$(git_config_get "prefix.team")"
rc_prefix_suggestion="$(git_config_get "prefix.rc")"
hf_prefix_suggestion="$(git_config_get "prefix.hf")"
integration_branch_suggestion="$(git_config_get "branch.integration")"
feature_prefix_suggestion="${feature_prefix_suggestion:-feature$prefix_delimiter}"
team_prefix_suggestion="${team_prefix_suggestion:-team$prefix_delimiter}"
rc_prefix_suggestion="${rc_prefix_suggestion:-rc$prefix_delimiter}"
hf_prefix_suggestion="${hf_prefix_suggestion:-hf$prefix_delimiter}"
integration_branch_suggestion="${integration_branch_suggestion:-integration}"
feature_prefix=$(io_prompt "feature prefix" "$feature_prefix_suggestion")
team_prefix=$(io_prompt "team prefix" "$team_prefix_suggestion")
release_candidate_prefix=$(io_prompt "release candidate prefix" "$rc_prefix_suggestion")
hot_fix_prefix=$(io_prompt "hot-fix prefix" "$hf_prefix_suggestion")
integration_branch=$(io_prompt "integration branch" "$integration_branch_suggestion")
io_log; git_v_ensure_branch "$integration_branch"
git_config_set "prefix.feature" "$feature_prefix"
git_config_set "prefix.team" "$team_prefix"
git_config_set "prefix.rc" "$release_candidate_prefix"
git_config_set "prefix.hf" "$hot_fix_prefix"
git_config_set "branch.integration" "$integration_branch"
git_config_set "initialized" true
io_log; io_log_ok "all done. you're awesome!"; io_log
}