Skip to content

Commit c6c817d

Browse files
jeromedalbertmatzbot
authored andcommitted
[rubygems/rubygems] Add --no-test, --no-ci, and --no-linter options
rubygems/rubygems@f58660ffcc
1 parent 04c86a6 commit c6c817d

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

lib/bundler/cli/gem.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def validate_ext_name
275275
end
276276

277277
def ask_and_set_test_framework
278+
return if skip?(:test)
278279
test_framework = options[:test] || Bundler.settings["gem.test"]
279280

280281
if test_framework.to_s.empty?
@@ -300,6 +301,10 @@ def ask_and_set_test_framework
300301
test_framework
301302
end
302303

304+
def skip?(option)
305+
options.key?(option) && options[option].nil?
306+
end
307+
303308
def hint_text(setting)
304309
if Bundler.settings["gem.#{setting}"] == false
305310
"Your choice will only be applied to this gem."
@@ -310,6 +315,7 @@ def hint_text(setting)
310315
end
311316

312317
def ask_and_set_ci
318+
return if skip?(:ci)
313319
ci_template = options[:ci] || Bundler.settings["gem.ci"]
314320

315321
if ci_template.to_s.empty?
@@ -341,6 +347,7 @@ def ask_and_set_ci
341347
end
342348

343349
def ask_and_set_linter
350+
return if skip?(:linter)
344351
linter_template = options[:linter] || Bundler.settings["gem.linter"]
345352
linter_template = deprecated_rubocop_option if linter_template.nil?
346353

lib/bundler/man/bundle-gem.1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ When Bundler is configured to not generate tests, an interactive prompt will be
4444
.IP
4545
When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
4646
.IP "\(bu" 4
47+
\fB\-\-no\-test\fR: Do not use a test framework (overrides \fB\-\-test\fR specified in the global config)\.
48+
.IP "\(bu" 4
4749
\fB\-\-ci\fR, \fB\-\-ci=github\fR, \fB\-\-ci=gitlab\fR, \fB\-\-ci=circle\fR: Specify the continuous integration service that Bundler should use when generating the project\. Acceptable values are \fBgithub\fR, \fBgitlab\fR and \fBcircle\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
4850
.IP
4951
When Bundler is configured to generate CI files, this defaults to Bundler's global config setting \fBgem\.ci\fR\.
@@ -52,6 +54,8 @@ When Bundler is configured to not generate CI files, an interactive prompt will
5254
.IP
5355
When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
5456
.IP "\(bu" 4
57+
\fB\-\-no\-ci\fR: Do not use a continuous integration service (overrides \fB\-\-ci\fR specified in the global config)\.
58+
.IP "\(bu" 4
5559
\fB\-\-linter\fR, \fB\-\-linter=rubocop\fR, \fB\-\-linter=standard\fR: Specify the linter and code formatter that Bundler should add to the project's development dependencies\. Acceptable values are \fBrubocop\fR and \fBstandard\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
5660
.IP
5761
When Bundler is configured to add a linter, this defaults to Bundler's global config setting \fBgem\.linter\fR\.
@@ -60,6 +64,8 @@ When Bundler is configured not to add a linter, an interactive prompt will be di
6064
.IP
6165
When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
6266
.IP "\(bu" 4
67+
\fB\-\-no\-linter\fR: Do not add a linter (overrides \fB\-\-linter\fR specified in the global config)\.
68+
.IP "\(bu" 4
6369
\fB\-e\fR, \fB\-\-edit[=EDITOR]\fR: Open the resulting GEM_NAME\.gemspec in EDITOR, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
6470
.IP "" 0
6571
.SH "SEE ALSO"

lib/bundler/man/bundle-gem.1.ronn

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ configuration file using the following names:
7676
the answer will be saved in Bundler's global config for future `bundle gem`
7777
use.
7878

79+
* `--no-test`:
80+
Do not use a test framework (overrides `--test` specified in the global
81+
config).
82+
7983
* `--ci`, `--ci=github`, `--ci=gitlab`, `--ci=circle`:
8084
Specify the continuous integration service that Bundler should use when
8185
generating the project. Acceptable values are `github`, `gitlab`
@@ -92,6 +96,10 @@ configuration file using the following names:
9296
the answer will be saved in Bundler's global config for future `bundle gem`
9397
use.
9498

99+
* `--no-ci`:
100+
Do not use a continuous integration service (overrides `--ci` specified in
101+
the global config).
102+
95103
* `--linter`, `--linter=rubocop`, `--linter=standard`:
96104
Specify the linter and code formatter that Bundler should add to the
97105
project's development dependencies. Acceptable values are `rubocop` and
@@ -108,6 +116,9 @@ configuration file using the following names:
108116
the answer will be saved in Bundler's global config for future `bundle gem`
109117
use.
110118

119+
* `--no-linter`:
120+
Do not add a linter (overrides `--linter` specified in the global config).
121+
111122
* `-e`, `--edit[=EDITOR]`:
112123
Open the resulting GEM_NAME.gemspec in EDITOR, or the default editor if not
113124
specified. The default is `$BUNDLER_EDITOR`, `$VISUAL`, or `$EDITOR`.

spec/bundler/commands/newgem_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,15 @@ def create_temporary_dir(dir)
937937
it_behaves_like "test framework is absent"
938938
end
939939

940+
context "gem.test setting set to a test framework and --no-test" do
941+
before do
942+
bundle "config set gem.test rspec"
943+
bundle "gem #{gem_name} --no-test"
944+
end
945+
946+
it_behaves_like "test framework is absent"
947+
end
948+
940949
context "--ci with no argument" do
941950
it "does not generate any CI config" do
942951
bundle "gem #{gem_name}"
@@ -1075,6 +1084,19 @@ def create_temporary_dir(dir)
10751084
end
10761085
end
10771086

1087+
context "gem.ci setting set to a CI service and --no-ci" do
1088+
before do
1089+
bundle "config set gem.ci github"
1090+
bundle "gem #{gem_name} --no-ci"
1091+
end
1092+
1093+
it "does not generate any CI config" do
1094+
expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to_not exist
1095+
expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to_not exist
1096+
expect(bundled_app("#{gem_name}/.circleci/config.yml")).to_not exist
1097+
end
1098+
end
1099+
10781100
context "--linter with no argument" do
10791101
it "does not generate any linter config" do
10801102
bundle "gem #{gem_name}"
@@ -1202,6 +1224,18 @@ def create_temporary_dir(dir)
12021224
end
12031225
end
12041226

1227+
context "gem.linter setting set to a linter and --no-linter" do
1228+
before do
1229+
bundle "config set gem.linter rubocop"
1230+
bundle "gem #{gem_name} --no-linter"
1231+
end
1232+
1233+
it "does not generate any linter config" do
1234+
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
1235+
expect(bundled_app("#{gem_name}/.standard.yml")).to_not exist
1236+
end
1237+
end
1238+
12051239
context "--edit option" do
12061240
it "opens the generated gemspec in the user's text editor" do
12071241
output = bundle "gem #{gem_name} --edit=echo"

0 commit comments

Comments
 (0)