mass_git_clone 0.2.0 → 0.3.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: 6b969ea7231a35d1bbc9c4187a44b7e055d65c0262e6c020487b9bf13fe07ed3
4
- data.tar.gz: 4de02c059fe9468eb88f2fb137ada652845c488291e32cd867d52abe0e6bb7e2
3
+ metadata.gz: 2d99032cd4324bcebc8fc4ce8ab96286a842e025d6987f2bd01ce241972c5327
4
+ data.tar.gz: 273485ce6b054fee8c4eff9f8ff0c772ccff1d54067beec64662adbfdb3c336d
5
5
  SHA512:
6
- metadata.gz: 907e419f6787819d380ea3ea400e05b94e8bb8c5f6f2588ebea3461e7f004c5f90962c23405991a7ee4f17e0224737e13e86e7a83f5a112444d0aac77cb12fc5
7
- data.tar.gz: 5c3ccf37dd923e7578aa3516552fc89f7ce60a0b074293878e5949b34ee058fb64ad2c784185e2e6700f57ba17092474161a89b83973ed08c9b22722a93c87b1
6
+ metadata.gz: 144bc9ddb230d9ef7c8f30500af417f3d9d50d7a02842b00f2957cf3e3216c37af63dbf1be857a3816641dfdc07fe1ae2a0b4c9cbc22f7ed6ed2dff801bd91b4
7
+ data.tar.gz: 59278b2564eb8b39289fc3ec6bd812ab3c0fdae59cc57084a2d7a085a568f7d9a71cc5addf55d75d4c5a4efc4d671f7b24521454b257f547971ab8bf4e52a2d4
@@ -13,12 +13,10 @@ jobs:
13
13
  strategy:
14
14
  matrix:
15
15
  ruby:
16
- - "2.7"
17
- - "3.0"
18
- - "3.1"
16
+ - "3.3"
19
17
 
20
18
  steps:
21
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
22
20
 
23
21
  - name: Setup ruby
24
22
  uses: ruby/setup-ruby@v1
@@ -38,10 +36,10 @@ jobs:
38
36
  runs-on: ubuntu-latest
39
37
 
40
38
  steps:
41
- - uses: actions/checkout@v3
39
+ - uses: actions/checkout@v4
42
40
 
43
41
  - name: Release Gem
44
- uses: discourse/publish-rubygems-action@v2
42
+ uses: discourse/publish-rubygems-action@v3
45
43
  env:
46
44
  RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
47
45
  GIT_EMAIL: team@discourse.org
data/.rubocop.yml CHANGED
@@ -2,4 +2,7 @@ inherit_gem:
2
2
  rubocop-discourse: stree-compat.yml
3
3
 
4
4
  Discourse/NoChdir:
5
- Enabled: false
5
+ Enabled: false
6
+
7
+ Discourse/Plugins/NamespaceMethods:
8
+ Enabled: false
data/bin/mass_git_clone CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative '../lib/mass_git_clone'
5
-
4
+ require_relative "../lib/mass_git_clone"
6
5
 
7
6
  if ARGV[0].nil? || ARGV.size > 1 || STDIN.tty?
8
7
  STDERR.puts "Usage `mass_git_clone <repo_base_directory>`. Pass newline-separated repo list via STDIN."
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "fileutils"
4
4
  require "open3"
5
- require "set"
6
5
  require "parallel"
7
6
 
8
7
  def run(*args)
@@ -30,8 +29,7 @@ end
30
29
  # Clone or update a repo with the given URL
31
30
  # On failure, return the repo url
32
31
  # On success, return nil
33
- def update_repo(repo_url)
34
- dir_name = File.basename(repo_url, ".git")
32
+ def update_repo(repo_url, dir_name)
35
33
  if Dir.exist?(dir_name)
36
34
  prefixed_puts "Updating #{dir_name}..."
37
35
 
@@ -71,21 +69,28 @@ module MassGitClone
71
69
  false
72
70
  end
73
71
 
74
- all_repos = repo_list.map(&:strip).filter { |l| l.length > 0 }
75
- if all_repos.size === 0
76
- prefixed_puts "No plugin URLs supplied"
72
+ all_entries = repo_list.map(&:strip).filter { |l| l.length > 0 }
73
+ if all_entries.size === 0
74
+ prefixed_puts "No git repository URLs supplied"
77
75
  exit 1
78
76
  end
79
77
 
80
- all_repos =
81
- all_repos.map do |repo|
82
- if !repo.match?(%r{\A[\w-]+/[\w-]+\z})
83
- repo # Full URL, leave untouched
84
- elsif use_ssh
85
- "git@github.com:#{repo}"
86
- else
87
- "https://github.com/#{repo}"
88
- end
78
+ all_entries =
79
+ all_entries.map do |entry|
80
+ repo, dir_name = entry.split(" ")
81
+
82
+ repo_url =
83
+ if !repo.match?(%r{\A[\w-]+/[\w-]+\z})
84
+ repo # Full URL, leave untouched
85
+ elsif use_ssh
86
+ "git@github.com:#{repo}"
87
+ else
88
+ "https://github.com/#{repo}"
89
+ end
90
+
91
+ dir_name ||= File.basename(repo_url, ".git")
92
+
93
+ [repo_url, dir_name]
89
94
  end
90
95
 
91
96
  Dir.mkdir(repo_base_dir) if !Dir.exist?(repo_base_dir)
@@ -93,13 +98,13 @@ module MassGitClone
93
98
  Dir.chdir(repo_base_dir) do
94
99
  failures =
95
100
  Parallel
96
- .map(all_repos, in_threads: ENV["PARALLEL"]&.to_i || 10) do |repo_url|
97
- update_repo(repo_url)
101
+ .map(all_entries, in_threads: ENV["PARALLEL"]&.to_i || 10) do |repo_url, dir_name|
102
+ update_repo(repo_url, dir_name)
98
103
  end
99
104
  .reject(&:nil?)
100
105
 
101
106
  final_dirs = Dir.glob("*")
102
- expected_dirs = Set.new(all_repos.map { |r| File.basename(r, ".git") })
107
+ expected_dirs = Set.new(all_entries.map { |_, dir_name| dir_name })
103
108
  to_delete = final_dirs.reject { |dir| expected_dirs.include?(dir) }
104
109
 
105
110
  if to_delete.any?
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "mass_git_clone"
8
- spec.version = "0.2.0"
8
+ spec.version = "0.3.0"
9
9
  spec.authors = ["Discourse Team"]
10
10
 
11
11
  spec.summary = %q{Tool for maintaining clones of a large number of git repositories}
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mass_git_clone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Discourse Team
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
10
+ date: 2025-01-31 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: parallel
@@ -95,7 +94,6 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  description: Tool for maintaining clones of a large number of git repositories
98
- email:
99
97
  executables:
100
98
  - mass_git_clone
101
99
  extensions: []
@@ -116,7 +114,6 @@ homepage: https://github.com/discourse/mass_git_clone
116
114
  licenses:
117
115
  - MIT
118
116
  metadata: {}
119
- post_install_message:
120
117
  rdoc_options: []
121
118
  require_paths:
122
119
  - lib
@@ -131,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
128
  - !ruby/object:Gem::Version
132
129
  version: '0'
133
130
  requirements: []
134
- rubygems_version: 3.1.6
135
- signing_key:
131
+ rubygems_version: 3.6.2
136
132
  specification_version: 4
137
133
  summary: Tool for maintaining clones of a large number of git repositories
138
134
  test_files: []