jackal-code-fetcher 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 256f04afa587e31c48aafa77aa2fc3261b725567
4
- data.tar.gz: 2642b577fca02320ce3eef689d1e7e62037e5ea3
3
+ metadata.gz: 215d1c0d6b8c6997b4474a34124024318f5ce105
4
+ data.tar.gz: 0cf8e802c632acc4b6be7c80e9b4441f3579fb91
5
5
  SHA512:
6
- metadata.gz: f2ddf0e3296657871dce882e18573cc0f4d1bdfa5be2189806a3448dbaa9f6a14f8eed3222c53e7d1bda0d6b40e431384b0af4e91cf6cdb513fbcbac65ce5fbf
7
- data.tar.gz: 5dcd3979d0545c31933095c1cd4b2c246a29820a6dfc8085ced701e385cb6266e7eb5e30d0d86f014e8161aafe95054b94a34def399a613a4c824539f140a6fd
6
+ metadata.gz: bbb0959c92dd1259ef4edcf6250ee3cd38db7e3d44f1d65d9d0ade459f1c807774f9bb4d543479ddbb7c86cd0e3df492adeeb8f8ee99a1759698f66d282e9029
7
+ data.tar.gz: ed8f3480738581419bd20a2705a08de7822182113a904e97c36b773a6e16162977f683f36c8d079a3bdb527fff5f5f350d96aa7309a647b7f417f065161305cb
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ # v0.1.2
2
+ * Synchronize repository directory access via lock file
3
+
1
4
  # v0.1.0
2
5
  * Initial release
@@ -37,6 +37,7 @@ module Jackal
37
37
  def execute(message)
38
38
  failure_wrap(message) do |payload|
39
39
  retried = false
40
+ locked = lock_repo(payload)
40
41
  begin
41
42
  store_reference(payload)
42
43
  rescue Git::GitExecuteError => e
@@ -48,11 +49,37 @@ module Jackal
48
49
  else
49
50
  raise
50
51
  end
52
+ ensure
53
+ unlock_repo(locked)
51
54
  end
52
55
  job_completed(:code_fetcher, payload, message)
53
56
  end
54
57
  end
55
58
 
59
+ # Lock repository via lock file
60
+ #
61
+ # @param payload[Smash]
62
+ # @return [File]
63
+ def lock_repo(payload)
64
+ lock_path = File.join(
65
+ working_directory,
66
+ "#{payload.get(:data, :code_fetcher, :info, :owner)}-" <<
67
+ "#{payload.get(:data, :code_fetcher, :info, :name)}.lock"
68
+ )
69
+ lock_file = File.open(lock_path, 'w')
70
+ lock_file.flock(File::LOCK_EX)
71
+ lock_file
72
+ end
73
+
74
+ # Unlock the repository via lock file
75
+ #
76
+ # @param lock_file [File]
77
+ # @return [File]
78
+ def unlock_repo(lock_file)
79
+ lock_file.close
80
+ lock_file
81
+ end
82
+
56
83
  # Delete local repository path
57
84
  #
58
85
  # @param payload [Smash]
@@ -1,6 +1,6 @@
1
1
  module Jackal
2
2
  module CodeFetcher
3
3
  # Current library version
4
- VERSION = Gem::Version.new('0.1.0')
4
+ VERSION = Gem::Version.new('0.1.2')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jackal-code-fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jackal
@@ -77,4 +77,3 @@ signing_key:
77
77
  specification_version: 4
78
78
  summary: Message processing helper
79
79
  test_files: []
80
- has_rdoc: