gitlab-mirror-pull 0.3.2 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3a69f7182c94ae3254645abc783683ecd7e4e5a95c33fedb9d2ecfd7baf2284
4
- data.tar.gz: 72dfca3933fa3cb0f535918315d21f6dde6e96fb47e506020735f12dd454c11e
3
+ metadata.gz: c8016146894292c81c368013de92acb4479279c0eb2cea7f03ade1c6a9fa4b8d
4
+ data.tar.gz: 2fd57a6bbdfb8f55c533f435111a33d33d88782e435a86171ef66e35a73894f1
5
5
  SHA512:
6
- metadata.gz: 136029157168d5028a479e26ca629195e422e6bf2aef0be0b8ba379f65b931cd3b9f26322fc25bde97f438f119de0397890f713b166aaec446d9a60c38a7ef6c
7
- data.tar.gz: ebf14424ebb898787b5d308138ae682af4908dab8c1e41a3acc923fb0bcef43c263e47a9aedab306d133cc35afffbcd6a82f54a97da272f6ab6c2d6611b208d8
6
+ metadata.gz: bdb0685b902726494e7daa0c986f03cad1563edcd673cfb78885951861e74ab9c3cb17e62c944082031bc2f8ae1ea7f3999ccfec495998a930b08994c28deb60
7
+ data.tar.gz: 97535c04d0ef00971c5075643a0b5f02404bf4393f06a873347588a331f72df6be5b8ca71037e595aa42d8878fa453a494aad8409130d857a0de3a60891fc6b4
@@ -63,6 +63,7 @@ if options[:run] == 'server'
63
63
  pull = GitlabMirrorPull.new(options[:config], options[:log_level])
64
64
 
65
65
  # Configure server
66
+ set :server, 'webrick'
66
67
  set :port, config['server']['port']
67
68
  set :bind, config['server']['bind']
68
69
  # Set to true to run sinatra webserver in production
@@ -70,10 +71,14 @@ if options[:run] == 'server'
70
71
 
71
72
  post '/commit' do
72
73
  gitlab_json = MultiJson.load(request.body.read)
73
- # File.join(File.dirname(__FILE__), "../config.example.yml")
74
74
  repo_path = File.join(config['git']['repos'], gitlab_json['project']['namespace'].downcase, gitlab_json['project']['name'].downcase + ".git")
75
- pull.fetch_repositories([repo_path])
76
- return ''
75
+
76
+ if File.exists?(repo_path)
77
+ pull.fetch_repositories([repo_path])
78
+ halt 200
79
+ else
80
+ halt 404
81
+ end
77
82
  end
78
83
 
79
84
  else
@@ -15,9 +15,7 @@ class GitlabMirrorPull
15
15
  #
16
16
  # @return Returns `@log` and `@config`
17
17
  #
18
- def initialize(config = File.join(File.dirname(__FILE__), "../config.example.yml"), log_level = Logger::ERROR)
19
-
20
- # Configure Logger
18
+ def initialize(config = File.join(File.dirname(__FILE__), "../config.yml"), log_level = Logger::ERROR)
21
19
  @log = Logger.new(STDOUT)
22
20
  @log.level = log_level
23
21
  @config = YAML.load_file(config)
@@ -29,7 +27,7 @@ class GitlabMirrorPull
29
27
  #
30
28
  def repositories_to_fetch
31
29
  # Find all .git Repositories - Ignore *.wiki.git
32
- repos = Dir.glob("#{config['git']['repos']}/*/*{[!.wiki]}.git")
30
+ repos = Dir.glob("#{@config['git']['repos']}/*/*{[!.wiki]}.git")
33
31
 
34
32
  # Build up array of NOT ignored repositories
35
33
  delete_path = []
@@ -53,7 +51,7 @@ class GitlabMirrorPull
53
51
  Git.configure do |config|
54
52
  config.binary_path = "#{@config['git']['path']}"
55
53
  end
56
-
54
+ @return_repos = []
57
55
  # Loop through repos and fetch it
58
56
  repos_to_fetch = repos.nil? ? self.repositories_to_fetch : repos
59
57
  repos_to_fetch.each do |repo|
@@ -65,11 +63,12 @@ class GitlabMirrorPull
65
63
  if @config['provider'].include?("#{remote}")
66
64
  @log.info("Fetching remote #{remote} in #{repo}")
67
65
  g.remote(remote).fetch
66
+ @return_repos << repo
68
67
  end
69
68
  end
70
69
  end
71
70
  end
72
-
71
+ @return_repos
73
72
  end
74
73
 
75
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-mirror-pull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ochorocho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-16 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git