git-check-ci 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/git-check-ci/checker.rb +3 -1
- data/lib/git-check-ci/formatter.rb +5 -7
- data/lib/git-check-ci/shell.rb +8 -1
- data/lib/git-check-ci/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -36,11 +36,11 @@ Run the setup command:
|
|
36
36
|
Setup is now complete. Doing a test run.
|
37
37
|
All good! Now the 'check' and 'fast-check' commands should work.
|
38
38
|
|
39
|
-
Add it to your prompt:
|
39
|
+
Add it to your prompt (simplistic example):
|
40
40
|
|
41
41
|
--- add me to e.g. ~/.profile ---
|
42
42
|
eval "$(git check-ci init)"
|
43
|
-
export PS1="\$(
|
43
|
+
export PS1="\[\$(_git_ci_color)\]\$(_git_ci_status) \u@\h\$"
|
44
44
|
|
45
45
|
Reload your shell:
|
46
46
|
|
@@ -79,5 +79,5 @@ The `GitCheckCI` shell helper does two things:
|
|
79
79
|
|
80
80
|
The spawned server check the CI status over HTTP every minute and stores the response in the Git configuration (used as an IPC of sorts).
|
81
81
|
|
82
|
-
It's done that way because `
|
82
|
+
It's done that way because the `_git_ci_*` shell functions need to be really, really fast---anything slower than 30ms will make your prompt feel unresponsive.
|
83
83
|
|
data/lib/git-check-ci/checker.rb
CHANGED
@@ -51,9 +51,11 @@ module GitCheckCI
|
|
51
51
|
|
52
52
|
# save the CI result to the Git config
|
53
53
|
def save(code_and_response)
|
54
|
+
color, icon = Formatter.handle_response(code_and_response)
|
54
55
|
@config.ci.last_checked = Time.now.strftime('%s')
|
55
56
|
@config.ci.response = code_and_response.to_json
|
56
|
-
@config.ci.
|
57
|
+
@config.ci.color = color
|
58
|
+
@config.ci.status = icon
|
57
59
|
nil
|
58
60
|
end
|
59
61
|
|
@@ -6,10 +6,10 @@ module GitCheckCI
|
|
6
6
|
|
7
7
|
def handle_response(data)
|
8
8
|
case data[:body]
|
9
|
-
when /failed/ then
|
10
|
-
when /(pending|building)/ then
|
11
|
-
when /[0-9a-f]{40}/ then
|
12
|
-
else
|
9
|
+
when /failed/ then [ color_code(:red), '✗' ]
|
10
|
+
when /(pending|building)/ then [ color_code(:gray), '•' ]
|
11
|
+
when /[0-9a-f]{40}/ then [ color_code(:green), '✔' ]
|
12
|
+
else [ color_code(:yellow), '!' ]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ module GitCheckCI
|
|
17
17
|
private
|
18
18
|
|
19
19
|
|
20
|
-
def
|
20
|
+
def color_code(color)
|
21
21
|
reset = "\033[0m"
|
22
22
|
color_code = case color
|
23
23
|
when :red then "\033[31m"
|
@@ -26,8 +26,6 @@ module GitCheckCI
|
|
26
26
|
when :gray then "\033[37m"
|
27
27
|
else ""
|
28
28
|
end
|
29
|
-
|
30
|
-
"#{color_code}#{symbol}#{reset}"
|
31
29
|
end
|
32
30
|
|
33
31
|
|
data/lib/git-check-ci/shell.rb
CHANGED
@@ -65,7 +65,10 @@ module GitCheckCI
|
|
65
65
|
desc "init", "Output shell config."
|
66
66
|
def init
|
67
67
|
puts %q[
|
68
|
-
|
68
|
+
_git_ci_color() {
|
69
|
+
git config ci.color 2>&1 || true
|
70
|
+
}
|
71
|
+
_git_ci_status() {
|
69
72
|
# exit early if not in a git repository
|
70
73
|
git status > /dev/null 2>&1 || return
|
71
74
|
|
@@ -81,6 +84,10 @@ module GitCheckCI
|
|
81
84
|
# try to return a status
|
82
85
|
git config ci.status 2> /dev/null || echo '?'
|
83
86
|
}
|
87
|
+
GitCheckCI() {
|
88
|
+
echo "*** GitCheckCI is deprecated, use _git_ci_status"
|
89
|
+
_git_ci_status
|
90
|
+
}
|
84
91
|
]
|
85
92
|
end
|
86
93
|
|
data/lib/git-check-ci/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-check-ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julien Letessier
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-09 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|