mass_git_clone 0.1.1 → 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: 41218ffbf93b188fad40acce7a6916da34d299f831ce964f341053174c13048f
4
- data.tar.gz: da292b0875d3ba36998c7d4e578f48adb927c97d20075017a208e70b118e5e0e
3
+ metadata.gz: 2d99032cd4324bcebc8fc4ce8ab96286a842e025d6987f2bd01ce241972c5327
4
+ data.tar.gz: 273485ce6b054fee8c4eff9f8ff0c772ccff1d54067beec64662adbfdb3c336d
5
5
  SHA512:
6
- metadata.gz: 0e5dc0d167ff609cb2e86db46ace0c064273238863ac555903f5eb400606b31e8fe1424d3d2b9ee5741aa297e2d37f20df1814117163abe3a95bf481ab07a33d
7
- data.tar.gz: c85e4402435b2c2d0c35cce951c84be433d5f1285c43d4d9f8ebfac785d6680aeb66971403ffc2e3ebf3f190b8a60ad60a07daab2cf2b1adcd33cfc504ebc2fa
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,11 +29,12 @@ 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
 
36
+ run "git", "-C", dir_name, "stash", "-u", "--quiet", "-m", "autostashed by mass_git_clone"
37
+
38
38
  run "git", "-C", dir_name, "remote", "set-url", "origin", repo_url
39
39
  run "git", "-C", dir_name, "remote", "set-head", "origin", "-a"
40
40
 
@@ -69,21 +69,28 @@ module MassGitClone
69
69
  false
70
70
  end
71
71
 
72
- all_repos = repo_list.map(&:strip).filter { |l| l.length > 0 }
73
- if all_repos.size === 0
74
- 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"
75
75
  exit 1
76
76
  end
77
77
 
78
- all_repos =
79
- all_repos.map do |repo|
80
- if !repo.match?(%r{\A[\w-]+/[\w-]+\z})
81
- repo # Full URL, leave untouched
82
- elsif use_ssh
83
- "git@github.com:#{repo}"
84
- else
85
- "https://github.com/#{repo}"
86
- 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]
87
94
  end
88
95
 
89
96
  Dir.mkdir(repo_base_dir) if !Dir.exist?(repo_base_dir)
@@ -91,13 +98,13 @@ module MassGitClone
91
98
  Dir.chdir(repo_base_dir) do
92
99
  failures =
93
100
  Parallel
94
- .map(all_repos, in_threads: ENV["PARALLEL"]&.to_i || 10) do |repo_url|
95
- 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)
96
103
  end
97
104
  .reject(&:nil?)
98
105
 
99
106
  final_dirs = Dir.glob("*")
100
- expected_dirs = Set.new(all_repos.map { |r| File.basename(r, ".git") })
107
+ expected_dirs = Set.new(all_entries.map { |_, dir_name| dir_name })
101
108
  to_delete = final_dirs.reject { |dir| expected_dirs.include?(dir) }
102
109
 
103
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.1.1"
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.1.1
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-01-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: []