github_snapshot 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmFmYmRjOTU2ZDRkZjhjMGUyNjIwZTFjZDA2NjViNWU3YWVlNDYxZQ==
4
+ ZWY1MjE0YmZmMjRjZjBlOWQ1OTA4YmRkOTc4OWE1MjliNWYzZDMzOA==
5
5
  data.tar.gz: !binary |-
6
- N2Q5NGVmNDEzZmEwODJiM2Y3ZTM2MTEyYzgwMzlhZDFlNzY1YTRiZA==
7
- !binary "U0hBNTEy":
6
+ NjJjNDZmMDdiNzk0M2M1NTA1NjI5NzA3MTA4OTBjZDc0Mjk1ZTE4ZA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- ODgyYTg5MGIwODA3YmU3ODljZDA1ODExNzhmOGI1YmRlOGFiYjcxNzJkMDg5
10
- ZDU5NzU3YWZiMmJhZGFjNmFmOWYzODQ4Mzc5NjQ3MWZiN2E2ZWE0MWJjNDFi
11
- NzUwMzRhMTQzMjU3ZGFhYTUwMmRlNjU1NTAwZjQ0NjU0NjdjNDI=
9
+ YzZmOTk3YWJhMWE5ODIwMjZiODAwYmYzODk0OTJmODAzN2EyMmM5OTdjNDRk
10
+ NjI2YWNjMjE3MzI2M2YxZDA5MmE3YTQwMzIzMzEyMWY3YjVkN2QxMjBhZTA3
11
+ YzdhYjRlY2Q0YjFlY2Q2MjI5NzYyZTNjZGJlOTQwNDRhZTZmYzA=
12
12
  data.tar.gz: !binary |-
13
- M2EzMzgwOGM0MDU4NzVlOTFhNjM3ODA3MzhkMjMwOGM5NDFlMWU3NjU5Yzdk
14
- ODMxYjlhNDc1Yzk1ZWNlY2FhZWVkNTFkNDk5NTAyZGQyZTU3Y2QyMTYyMmE3
15
- MmQ5MGM4OTUxNmQxN2QwMzNlMGNhOWU2OWQzZDM2NTE3ZTc2NjY=
13
+ NTBkZDc2MzFmNDQ1NDZlNDY5MDU1NzFkOTRhOWVlOGUwOGEyYjU3NjE5MDVm
14
+ MDA1YTc4MzQ1ZjYyNTM5NzIxYWY4NzkxYTdjYWQyMjMxMzhlZTBlMjgzYjVk
15
+ MWExZWUyYjA1YjAyN2Q2NWQzMzNlZjMzNjMzYjljMjYzZTE0ZDM=
@@ -1,5 +1,4 @@
1
1
  require "github_snapshot/snapshot"
2
2
 
3
3
  module GithubSnapshot
4
- # Your code goes here...
5
4
  end
@@ -24,30 +24,30 @@ module GithubSnapshot
24
24
  end
25
25
 
26
26
  def has_wiki?
27
- Open3.capture3("git ls-remote #{wiki_ssh_url}")[1].empty? && gh_has_wiki
27
+ Open3.capture3("git ls-remote #{@wiki_ssh_url}")[1].empty? && @gh_has_wiki
28
28
  end
29
29
 
30
30
  def backup
31
- GithubSnapshot.logger.info "#{canonical_name} - backing up"
31
+ GithubSnapshot.logger.info "#{@canonical_name} - backing up"
32
32
 
33
33
  # Go to next repo if the repository is empty
34
- unless pushed_at
35
- GithubSnapshot.logger.info "#{canonical_name} is empty"
34
+ unless @pushed_at
35
+ GithubSnapshot.logger.info "#{@canonical_name} is empty"
36
36
  return nil
37
37
  end
38
38
 
39
+ Dir.chdir "#{@organization.name}"
39
40
  begin
40
- Dir.chdir "#{organization.name}"
41
41
  clone
42
- clone_wiki if self.has_wiki?
42
+ clone_wiki if has_wiki?
43
43
  prune_old_backups
44
- Dir.chdir ".."
45
44
  rescue GithubSnapshot::Error
46
- GithubSnapshot.logger.error "#{canonical_name} - skipping due to error"
45
+ GithubSnapshot.logger.error "#{@canonical_name} - skipping due to error"
47
46
  return nil
48
47
  end
48
+ Dir.chdir ".."
49
49
 
50
- GithubSnapshot.logger.info "#{canonical_name} - success"
50
+ GithubSnapshot.logger.info "#{@canonical_name} - success"
51
51
  end
52
52
 
53
53
  private
@@ -59,34 +59,34 @@ module GithubSnapshot
59
59
  # Timeout to make sure the script doesn't hang
60
60
  begin
61
61
  Timeout::timeout (GithubSnapshot.git_clone_timeout) {
62
- GithubSnapshot.exec "#{GithubSnapshot.git_clone_cmd} #{ssh_url} #{folder}"
62
+ GithubSnapshot.exec "#{GithubSnapshot.git_clone_cmd} #{@ssh_url} #{@folder}"
63
63
  }
64
64
  rescue Timeout::Error, Utilities::ExecError => e
65
65
  message = e.class == Timeout::Error ? 'timedout' : 'exec error'
66
- GithubSnapshot.logger.error "Could not clone #{canonical_name}, #{message}"
66
+ GithubSnapshot.logger.error "Could not clone #{@canonical_name}, #{message}"
67
67
  raise GithubSnapshot::Error
68
68
  end
69
69
 
70
- Utilities.tar "#{folder}", GithubSnapshot.logger
71
- GithubSnapshot.exec "rm -rf #{folder}"
70
+ Utilities.tar "#{@folder}", GithubSnapshot.logger
71
+ GithubSnapshot.exec "rm -rf #{@folder}"
72
72
  end
73
73
 
74
74
  def clone_wiki
75
- GithubSnapshot.logger.info "#{canonical_name} - cloning wiki"
76
- GithubSnapshot.exec "#{GithubSnapshot.git_clone_cmd} #{wiki_ssh_url} #{wiki_folder}"
77
- Utilities.tar "#{wiki_folder}", GithubSnapshot.logger
78
- GithubSnapshot.exec "rm -rf #{wiki_folder}"
75
+ GithubSnapshot.logger.info "#{@canonical_name} - cloning wiki"
76
+ GithubSnapshot.exec "#{GithubSnapshot.git_clone_cmd} #{@wiki_ssh_url} #{@wiki_folder}"
77
+ Utilities.tar "#{@wiki_folder}", GithubSnapshot.logger
78
+ GithubSnapshot.exec "rm -rf #{@wiki_folder}"
79
79
  end
80
80
 
81
81
  def prune_old_backups
82
- GithubSnapshot.logger.info "#{canonical_name} - pruning old backups"
83
- file_regex = "#{name}-GST-*"
82
+ GithubSnapshot.logger.info "#{@canonical_name} - pruning old backups"
83
+ file_regex = "#{@name}-GST-*tar.gz"
84
84
  zipped_bkps = FileList[file_regex].exclude(/wiki/)
85
85
  zipped_bkps.sort[0..-(GithubSnapshot.releases_to_keep + 1)].each do |file|
86
86
  File.delete file
87
87
  end if zipped_bkps.length > GithubSnapshot.releases_to_keep
88
88
 
89
- wiki_regex = "#{name}-GST-*wiki*"
89
+ wiki_regex = "#{@name}-GST-*wiki*"
90
90
  zipped_wikis = FileList[wiki_regex]
91
91
  zipped_wikis.sort[0..-(GithubSnapshot.releases_to_keep + 1)].each do |file|
92
92
  File.delete file
@@ -72,7 +72,7 @@ module GithubSnapshot
72
72
  def download_from_s3
73
73
  GithubSnapshot.logger.info "downloading fom s3"
74
74
  begin
75
- GithubSnapshot.exec "s3cmd sync --delete-removed s3://#{s3_bucket}/ #{backup_folder}/"
75
+ GithubSnapshot.exec "s3cmd sync --delete-removed --skip-existing s3://#{s3_bucket}/ #{backup_folder}/"
76
76
  rescue Utilities::ExecError
77
77
  GithubSnapshot.logger.info "s3cmd doesn't respect exit status\n"\
78
78
  "there is a good chance that the sync was successful"
@@ -93,7 +93,7 @@ module GithubSnapshot
93
93
 
94
94
  def upload_to_s3
95
95
  GithubSnapshot.logger.info "uploading to s3"
96
- GithubSnapshot.exec "s3cmd sync --delete-removed #{backup_folder}/ s3://#{s3_bucket}/"
96
+ GithubSnapshot.exec "s3cmd sync --delete-removed --skip-existing #{backup_folder}/ s3://#{s3_bucket}/"
97
97
  end
98
98
 
99
99
  end
@@ -1,3 +1,3 @@
1
1
  module GithubSnapshot
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Rodrigues
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-31 00:00:00.000000000 Z
12
+ date: 2013-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.0.7
113
+ rubygems_version: 2.1.5
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Snapshots Github repositories