Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 27, 2012
@theory Write engine section header if no vars.
Otherwise it's missing. So write it out as a comment, so that it will properly appear.
b2243bd
@theory Show commented-out engine config in tutorial. f5a1c8a
View
9 lib/App/Sqitch/Command/init.pm
@@ -138,8 +138,13 @@ sub write_config {
}
}
- # Emit them.
- $config->group_set($file => \@vars) if @vars;
+ if (@vars) {
+ # Emit them.
+ $config->group_set($file => \@vars) if @vars;
+ } else {
+ # Still want the section, emit it as a comment.
+ unshift @comments => '[core "' . $engine->name . '"]';
+ }
# Emit the comments.
$config->add_comment(
View
18 lib/sqitchtutorial.pod
@@ -44,14 +44,22 @@ Now that we have a repository, let's get started with Sqitch.
Let's have a look at F<sqitch.conf>:
- [core]
- engine = pg
- # sql_dir = sql
- # extension = sql
+ # [core "pg"]
+ # db_name =
+ # client = psql
+ # sqitch_schema = sqitch
+ # password =
+ # port =
+ # host =
+ # username =
Pretty simple. It picked up on the fact that we're creating changes for the
PostgreSQL engine, thanks to the C<--engine pg> option, and saved it to the
-file. By default, Sqitch will read F<sqitch.conf> in the current directory for
+file. It also wrote a commented-out C<[core "pg"]> section with all the
+available PostgreSQL engine-specific settings commented out and ready to be
+edited as appropriate.
+
+By default, Sqitch will read F<sqitch.conf> in the current directory for
settings. But it will also read F<~/.sqitch/sqitch.conf> for global settings.
Since PostgreSQL's C<psql> client is not in the path on my system, let's go
ahead an tell it globally where to find the client:
View
45 t/init.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use v5.10.1;
use utf8;
-use Test::More tests => 77;
+use Test::More tests => 87;
#use Test::More 'no_plan';
use App::Sqitch;
use Path::Class;
@@ -225,6 +225,25 @@ is_deeply read_config $conf_file, {
file_contents_like $conf_file, qr/^\t# sqitch_prefix = sqitch\n/m,
'sqitch_prefix should be included in a comment';
+# Try it with no options.
+unlink $conf_file;
+$sqitch = App::Sqitch->new(_engine => 'sqlite');
+ok $init = $CLASS->new(sqitch => $sqitch),
+ 'Create new init with sqitch with default engine attributes';
+ok $init->write_config, 'Write the config with engine attrs';
+is_deeply +MockCommand->get_info, [
+ ['Created ' . $conf_file]
+], 'The creation should be sent to info again again';
+is_deeply read_config $conf_file, {
+ 'core.engine' => 'sqlite',
+}, 'The configuration should have been written with only the engine var';
+
+file_contents_like $conf_file, qr{^\Q# [core "sqlite"]
+ # sqitch_prefix = sqitch
+ # db_name =
+ # client = sqlite3
+}m, 'Engine section should be present but commented-out';
+
# Now build it with other config.
USERCONF: {
# Delete the file and write with a user config loaded.
@@ -287,6 +306,29 @@ file_contents_like $conf_file, qr/^\t# sqitch_schema = sqitch\n/m,
file_contents_like $conf_file, qr/^\t# password = \n/m,
'password should be included in a comment';
+# Try it with no config or options.
+unlink $conf_file;
+$sqitch = App::Sqitch->new(_engine => 'pg');
+ok $init = $CLASS->new(sqitch => $sqitch),
+ 'Create new init with sqitch with default engine attributes';
+ok $init->write_config, 'Write the config with engine attrs';
+is_deeply +MockCommand->get_info, [
+ ['Created ' . $conf_file]
+], 'The creation should be sent to info again again again';
+is_deeply read_config $conf_file, {
+ 'core.engine' => 'pg',
+}, 'The configuration should have been written with only the engine var';
+
+file_contents_like $conf_file, qr{^\Q# [core "pg"]
+ # db_name =
+ # client = psql
+ # sqitch_schema = sqitch
+ # password =
+ # port =
+ # host =
+ # username =
+}m, 'Engine section should be present but commented-out';
+
USERCONF: {
# Delete the file and write with a user config loaded.
unlink $conf_file;
@@ -299,7 +341,6 @@ USERCONF: {
'Make an init with pg and user config';
file_not_exists_ok $conf_file;
ok $init->write_config, 'Write the config with pg config';
-
is_deeply +MockCommand->get_info, [
['Created ' . $conf_file]
], 'The pg config creation should be sent to info';

No commit comments for this range

Something went wrong with that request. Please try again.