gitdocs 0.1.3 → 0.1.4

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.
@@ -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 origin/master")
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 origin master")
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)
@@ -1,3 +1,3 @@
1
1
  module Gitdocs
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gitdocs
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Hull