-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitflux-validation
82 lines (68 loc) · 1.85 KB
/
gitflux-validation
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
#!/usr/bin/env bash
require_args() {
for arg; do
if [[ -z $arg ]]; then
usage
fi
done
}
require_gitflux_initialized() {
if [[ $(git_config_get "initialized") != true ]]; then
io_log; io_status_fatal "git-flux is not initialized. run 'git flux init' to fix this."
fi
}
require_non_empty_repository() {
if git_repo_is_empty; then
if ! git_pull_origin "master" && git_repo_is_empty; then
io_log; io_status_fatal "repository is empty, add some changes to fix this."
fi
fi
}
validate_git_clean_working_tree() {
if ! git_is_clean_working_tree; then
io_status_fatal "working tree is not clean. make sure all changes are commited, or stash them."
fi
}
validate_git_local_branch_exists() {
if ! git_local_branch_exists "$1"; then
io_status_fatal "branch '$1' doesn't exist locally."
fi
}
validate_git_remote_branch_exists() {
if ! git_remote_branch_exists "$1"; then
io_status_fatal "branch '$1' doesn't exist on the remote."
fi
}
validate_git_local_branch_dont_exist() {
if git_local_branch_exists "$1"; then
io_status_fatal "branch '$1' already exists locally."
fi
}
validate_git_remote_branch_dont_exist() {
if git_remote_branch_exists "$1"; then
io_status_fatal "branch '$1' already exists on the remote."
fi
}
validate_git_local_and_remote_branches_exist() {
validate_git_local_branch_exists "$1"
validate_git_remote_branch_exists "$1"
}
validate_git_local_and_remote_branches_dont_exist() {
validate_git_local_branch_dont_exist "$1"
validate_git_remote_branch_dont_exist "$1"
}
validate_git_local_or_remote_branch_exists() {
if ! git_branch_exists "$1"; then
io_status_fatal "branch '$1' doesn't exist."
fi
}
validate_git_tag_exists() {
if ! git_tag_exists "$1"; then
io_status_fatal "tag '$1' doesn't exist."
fi
}
validate_git_tag_not_exists() {
if git_tag_exists "$1"; then
io_status_fatal "tag '$1' already exists."
fi
}