gitdocs 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gitdocs/runner.rb +10 -2
- data/lib/gitdocs/version.rb +1 -1
- metadata +1 -1
data/lib/gitdocs/runner.rb
CHANGED
@@ -12,13 +12,15 @@ module Gitdocs
|
|
12
12
|
|
13
13
|
def run
|
14
14
|
info("Running gitdocs!", "Running gitdocs in `#{@root}'")
|
15
|
+
@current_remote = sh_string("git config branch.`git branch | grep '^\*' | sed -e 's/\* //'`.remote", "origin")
|
16
|
+
@current_branch = sh_string("git branch | grep '^\*' | sed -e 's/\* //'", "master")
|
15
17
|
@current_revision = sh("git rev-parse HEAD").strip rescue nil
|
16
18
|
mutex = Mutex.new
|
17
19
|
Thread.new do
|
18
20
|
loop do
|
19
21
|
mutex.synchronize do
|
20
22
|
begin
|
21
|
-
out, status = sh_with_code("git fetch --all && git merge
|
23
|
+
out, status = sh_with_code("git fetch --all && git merge #{@current_remote}/#{@current_branch}")
|
22
24
|
if status.success?
|
23
25
|
changes = get_latest_changes
|
24
26
|
unless changes.empty?
|
@@ -55,7 +57,7 @@ module Gitdocs
|
|
55
57
|
# TODO make this message nicer
|
56
58
|
sh "git commit -a -m'Auto-commit from gitdocs'" unless sh("git status -s").strip.empty?
|
57
59
|
if @current_revision.nil?
|
58
|
-
out, code = sh_with_code("git push
|
60
|
+
out, code = sh_with_code("git push #{@current_remote} #{@current_branch}")
|
59
61
|
if code.success?
|
60
62
|
changes = get_latest_changes
|
61
63
|
info("Pushed #{changes.size} change#{changes.size == 1 ? '' : 's'}", "`#{@root}' has been pushed")
|
@@ -116,6 +118,12 @@ module Gitdocs
|
|
116
118
|
raise
|
117
119
|
end
|
118
120
|
|
121
|
+
# sh_string("git config branch.`git branch | grep '^\*' | sed -e 's/\* //'`.remote", "origin")
|
122
|
+
def sh_string(cmd, default)
|
123
|
+
val = sh(cmd).strip rescue nil
|
124
|
+
(val.nil? || val.empty?) ? default : val
|
125
|
+
end
|
126
|
+
|
119
127
|
def sh(cmd)
|
120
128
|
out, code = sh_with_code(cmd)
|
121
129
|
code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
|
data/lib/gitdocs/version.rb
CHANGED