obazoud-git-external 0.1.5 → 0.2.0
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/bin/git-external +21 -4
- metadata +4 -4
data/bin/git-external
CHANGED
@@ -56,6 +56,12 @@ def normalize_url(url)
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# Check for uncommitted changes
|
60
|
+
def uncommitted_changes?(path)
|
61
|
+
diffExit, diff = execute("cd #{path}; git diff-index --quiet HEAD")
|
62
|
+
return ((diffExit == 1) ? true : false)
|
63
|
+
end
|
64
|
+
|
59
65
|
# Check if a branch exists
|
60
66
|
def branch_exists(path, branch)
|
61
67
|
branches = `cd #{path}; git branch`
|
@@ -87,8 +93,13 @@ end
|
|
87
93
|
|
88
94
|
def update_external(url, path, branch='master')
|
89
95
|
require 'fileutils'
|
96
|
+
puts "- Updating #{path}"
|
90
97
|
if File.directory? "#{path}/.git"
|
91
|
-
|
98
|
+
if uncommitted_changes?(path)
|
99
|
+
puts "#{path} - uncommitted changes detected, can not update repository"
|
100
|
+
else
|
101
|
+
`cd #{path}; git pull origin #{branch}`
|
102
|
+
end
|
92
103
|
end
|
93
104
|
end
|
94
105
|
|
@@ -112,20 +123,26 @@ def command_status
|
|
112
123
|
gitBranchExit, gitBranch = execute("cd #{path} && git config \"branch.$(git symbolic-ref HEAD --short).merge\" | sed \"s/refs\\/heads\\///g\"")
|
113
124
|
gitRemoteExit, gitRemote = execute("cd #{path} && git config \"remote.$(git config \"branch.$(git symbolic-ref HEAD --short).remote\").url\"");
|
114
125
|
|
126
|
+
if uncommitted_changes?(path)
|
127
|
+
changesString = "(Uncommitted Changes) "
|
128
|
+
else
|
129
|
+
changesString = ""
|
130
|
+
end
|
131
|
+
|
115
132
|
if gitBranchExit != 0 && gitRemoteExit != 0
|
116
133
|
puts " ✗ #{path}: exit code #{gitBranchExit}, #{gitRemoteExit}"
|
117
134
|
broken += 1
|
118
135
|
else
|
119
136
|
if branch == gitBranch[0]
|
120
137
|
if url == gitRemote[0]
|
121
|
-
puts " ✓ #{path}"
|
138
|
+
puts " ✓ #{path} #{changesString}"
|
122
139
|
ok += 1
|
123
140
|
else
|
124
|
-
puts " ✗ #{path} -- expected url '#{url}' but was '#{gitRemote[0]}'"
|
141
|
+
puts " ✗ #{path} #{changesString} -- expected url '#{url}' but was '#{gitRemote[0]}'"
|
125
142
|
broken +=1
|
126
143
|
end
|
127
144
|
else
|
128
|
-
puts " ✗ #{path} -- expected branch '#{branch}' but was '#{gitBranch[0]}'"
|
145
|
+
puts " ✗ #{path} #{changesString} -- expected branch '#{branch}' but was '#{gitBranch[0]}'"
|
129
146
|
broken +=1
|
130
147
|
end
|
131
148
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obazoud-git-external
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Cestari
|