rebuild 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rebuild/repository.rb +25 -26
- data/lib/rebuild/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5e6f743ea4800a0758acc8d4741e512a78705a4
|
4
|
+
data.tar.gz: 02212939decd5c08df98de2b53a649cb6a1a1eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfe9c634f3d0b227998f55cdcf0a9b22a256a002eceb1b84b70d1d5054d6128faa07ce95b87896f3b2647cf22cd115b7d0664ef789a077abff0084550f99dc54
|
7
|
+
data.tar.gz: 71ef170f0534e471efeae2337765a50cbd9f9ef9d812d970ae894d35cf0eae0a9ad280106c609ca7a207902c0f748a895a0fb1bcccb80da47af5349c80e311c6
|
data/lib/rebuild/repository.rb
CHANGED
@@ -14,36 +14,43 @@ module Rebuild
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def fetch
|
17
|
-
|
18
|
-
|
17
|
+
if File.exists?(repo_path)
|
18
|
+
sync_repository
|
19
|
+
else
|
20
|
+
clone_repository
|
21
|
+
end
|
19
22
|
|
20
23
|
repo_path
|
21
24
|
end
|
22
25
|
|
23
26
|
private
|
24
27
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
def clone_repository
|
29
|
+
FileUtils.mkdir_p(user_path)
|
30
|
+
`git clone #{github_repository} #{repo_path}`
|
31
|
+
end
|
32
|
+
|
33
|
+
def sync_repository
|
34
|
+
if dirty_repository?
|
35
|
+
puts 'Repository has unstaged changes. Sync skipped.'
|
36
|
+
else
|
37
|
+
run_with_repository('git pull origin master')
|
29
38
|
end
|
39
|
+
end
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
unzip_archive
|
34
|
-
FileUtils.rm(archive_path)
|
35
|
-
puts " done."
|
41
|
+
def dirty_repository?
|
42
|
+
run_with_repository('[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]')
|
36
43
|
end
|
37
44
|
|
38
|
-
def
|
39
|
-
|
45
|
+
def run_with_repository(script)
|
46
|
+
system(<<-EOS)
|
47
|
+
cd #{repo_path}
|
48
|
+
#{script}
|
49
|
+
EOS
|
40
50
|
end
|
41
51
|
|
42
|
-
def
|
43
|
-
|
44
|
-
unzipped_path = File.join(user_path, "#{@repo}-#{@reference}")
|
45
|
-
FileUtils.rm_rf(repo_path)
|
46
|
-
FileUtils.mv(unzipped_path, repo_path)
|
52
|
+
def github_repository
|
53
|
+
"git@github.com:#{@user}/#{@repo}"
|
47
54
|
end
|
48
55
|
|
49
56
|
def repo_path
|
@@ -53,13 +60,5 @@ module Rebuild
|
|
53
60
|
def user_path
|
54
61
|
File.join(FETCH_DIRECTORY, @user)
|
55
62
|
end
|
56
|
-
|
57
|
-
def archive_path
|
58
|
-
File.join(user_path, "#{@repo}.zip")
|
59
|
-
end
|
60
|
-
|
61
|
-
def archive_url
|
62
|
-
"https://github.com/#{@user}/#{@repo}/archive/#{@reference}.zip"
|
63
|
-
end
|
64
63
|
end
|
65
64
|
end
|
data/lib/rebuild/version.rb
CHANGED