Skip to content

Commit 4981b45

Browse files
committed
Remove git file lists from gemspecs so integration testing works
1 parent 09f4fa0 commit 4981b45

6 files changed

Lines changed: 58 additions & 37 deletions

File tree

Rakefile

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,52 @@ end
6262

6363
namespace :gem do
6464
# Define global tasks for all gems
65-
%i[build clean install install:local release uninstall].each do |task|
65+
%i[build clean install install:local uninstall].each do |task|
6666
desc "#{task.capitalize} all gems"
6767
task task do
6868
Terminalwire::Project.all.each do |project|
6969
project.rake_task(task).invoke
7070
end
7171
end
7272
end
73+
74+
namespace :releasable do
75+
desc "Ensure git working directory is clean"
76+
task :clean do
77+
unless system("git diff-index --quiet HEAD --")
78+
abort "Git working directory is not clean. Please commit or stash changes before release."
79+
end
80+
puts "Git working directory is clean."
81+
end
82+
83+
desc "Ensure local branch is in sync with its upstream"
84+
task :synced do
85+
system("git fetch") || abort("Failed to fetch updates from origin.")
86+
87+
local = `git rev-parse @`.strip
88+
remote = `git rev-parse @{u}`.strip rescue nil
89+
90+
if remote.nil?
91+
abort "No upstream branch configured for the current branch."
92+
end
93+
94+
if local != remote
95+
abort "Local branch (#{local}) does not match remote (#{remote}). Please commit and push all changes."
96+
end
97+
98+
puts "Local branch is in sync with the remote."
99+
end
100+
end
101+
102+
desc "Check if gem is releasable: clean working directory and synced branch"
103+
task releasable: %i[releasable:clean releasable:synced]
104+
105+
desc "Release all gems"
106+
task release: :releasable do
107+
Terminalwire::Project.all.each do |project|
108+
project.rake_task("release").invoke
109+
end
110+
end
73111
end
74112

75113
desc "Build gems"

gem/terminalwire-client/terminalwire-client.gemspec

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ Gem::Specification.new do |spec|
1919

2020
# Specify which files should be added to the gem when it is released.
2121
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22-
gemspec = File.basename(__FILE__)
23-
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
24-
ls.readlines("\x0", chomp: true).reject do |f|
25-
(f == gemspec) ||
26-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27-
end
28-
end
22+
# Specify which files should be added to the gem when it is released.
23+
spec.files = (
24+
Dir.glob("{lib,exe,ext}/**/*") + Dir.glob("{README*,LICENSE*}")
25+
).select { |f| File.file?(f) }
2926
spec.require_paths = core.require_paths
3027

3128
# Uncomment to register a new dependency of your gem

gem/terminalwire-core/terminalwire-core.gemspec

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ Gem::Specification.new do |spec|
2323

2424
# Specify which files should be added to the gem when it is released.
2525
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26-
gemspec = File.basename(__FILE__)
27-
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
28-
ls.readlines("\x0", chomp: true).reject do |f|
29-
(f == gemspec) ||
30-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
31-
end
32-
end
26+
# Specify which files should be added to the gem when it is released.
27+
spec.files = (
28+
Dir.glob("{lib,exe,ext}/**/*") + Dir.glob("{README*,LICENSE*}")
29+
).select { |f| File.file?(f) }
3330
spec.require_paths = ["lib"]
3431

3532
# Uncomment to register a new dependency of your gem

gem/terminalwire-rails/terminalwire-rails.gemspec

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ Gem::Specification.new do |spec|
1919

2020
# Specify which files should be added to the gem when it is released.
2121
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22-
gemspec = File.basename(__FILE__)
23-
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
24-
ls.readlines("\x0", chomp: true).reject do |f|
25-
(f == gemspec) ||
26-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27-
end
28-
end
22+
# Specify which files should be added to the gem when it is released.
23+
spec.files = (
24+
Dir.glob("{lib,exe,ext,rails}/**/*") + Dir.glob("{README*,LICENSE*}")
25+
).select { |f| File.file?(f) }
2926
spec.require_paths = core.require_paths
3027

3128
# Uncomment to register a new dependency of your gem

gem/terminalwire-server/terminalwire-server.gemspec

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ Gem::Specification.new do |spec|
1919

2020
# Specify which files should be added to the gem when it is released.
2121
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22-
gemspec = File.basename(__FILE__)
23-
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
24-
ls.readlines("\x0", chomp: true).reject do |f|
25-
(f == gemspec) ||
26-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27-
end
28-
end
22+
# Specify which files should be added to the gem when it is released.
23+
spec.files = (
24+
Dir.glob("{lib,exe,ext}/**/*") + Dir.glob("{README*,LICENSE*}")
25+
).select { |f| File.file?(f) }
2926
spec.require_paths = core.require_paths
3027

3128
# Uncomment to register a new dependency of your gem

gem/terminalwire/terminalwire.gemspec

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ Gem::Specification.new do |spec|
1818
spec.metadata["source_code_uri"] = "https://github.com/terminalwire/ruby/tree/main/#{spec.name}"
1919

2020
# Specify which files should be added to the gem when it is released.
21-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22-
gemspec = File.basename(__FILE__)
23-
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
24-
ls.readlines("\x0", chomp: true).reject do |f|
25-
(f == gemspec) ||
26-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27-
end
28-
end
21+
spec.files = (
22+
Dir.glob("{lib,exe,ext}/**/*") + Dir.glob("{README*,LICENSE*}")
23+
).select { |f| File.file?(f) }
2924

3025
spec.bindir = "exe"
3126
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }

0 commit comments

Comments
 (0)