Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
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.
...
  • 2 commits
  • 20 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 20, 2012
@theory Add the `%uri` pragma and accessor. ee814d1
@theory Remove App::Sqitch `uri` attribute.
Haven't been using it for a few days, and now we have the Plan `uri`
attribute, which will soon be put to use.
ddb0a2e
View
24 lib/App/Sqitch.pm
@@ -198,22 +198,6 @@ has editor => (
}
);
-has uri => (
- is => 'ro',
- isa => 'URI',
- required => 1,
- lazy => 1,
- default => sub {
- my $uri = shift->config->get( key => 'core.uri' ) or hurl core => __x(
- 'Missing project URI. Run {command} to add a URI',
- command => '`sqitch config core.uri URI`'
- );
-
- require URI;
- return URI->new($uri);
- }
-);
-
has pager => (
is => 'ro',
required => 1,
@@ -289,7 +273,6 @@ sub _core_opts {
db-username|db-user|u=s
db-host=s
db-port=i
- uri=s
top-dir|dir=s
deploy-dir=s
revert-dir=s
@@ -367,9 +350,6 @@ sub _parse_core_opts {
}
$opts{plan_file} = file $opts{plan_file} if defined $opts{plan_file};
- # Convert URI to URI.
- $opts{uri} = do { require URI; URI->new($opts{uri}) } if $opts{uri};
-
# Normalize the options (remove undefs) and return.
$opts{verbosity} = delete $opts{verbose};
delete $opts{$_} for grep { !defined $opts{$_} } keys %opts;
@@ -706,14 +686,10 @@ it.
=over
-=item * Add a project name as a plan pragma.
-
=item * Add cross-project dependency specification using project name.
=item * Add option to `init` to add/change the name pragma.
-=item * Move the URI to a pragma.
-
=item * Add URI to info only if set?
=item * Add custom formatting support to C<status>.
View
30 lib/App/Sqitch/Plan.pm
@@ -41,6 +41,28 @@ has position => (
default => -1,
);
+has project => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1,
+ lazy => 1,
+ default => sub {
+ shift->_plan->{pragmas}{project};
+ }
+);
+
+has uri => (
+ is => 'ro',
+ isa => 'Maybe[URI]',
+ required => 0,
+ lazy => 1,
+ default => sub {
+ my $uri = shift->_plan->{pragmas}{uri} || return;
+ require URI;
+ URI->new($uri);
+ }
+);
+
sub load {
my $self = shift;
my $file = $self->sqitch->plan_file;
@@ -435,7 +457,6 @@ sub open_script {
}
sub syntax_version { shift->_plan->{pragmas}{syntax_version} };
-sub project { shift->_plan->{pragmas}{project} };
sub lines { shift->_plan->{lines}->items }
sub changes { shift->_plan->{changes}->changes }
sub tags { shift->_plan->{changes}->tags }
@@ -736,6 +757,13 @@ C<next> returns C<undef>, the value will be the last index in the plan plus 1.
Returns the name of the project as set via the C<%project> pragma in the plan
file.
+=head3 C<uri>
+
+ my $uri = $plan->uri;
+
+Returns the URI for the project as set via the C<%uri> pragma, which is
+optional. If it is not present, C<undef> will be returned.
+
=head3 C<syntax_version>
my $syntax_version = $plan->syntax_version;
View
10 lib/sqitch-config.pod
@@ -249,7 +249,6 @@ Given a F<./sqitch.conf> like this:
; core variables
[core]
- uri = https://github.com/theory/sqitch/
; Use PostgreSQL
engine = pg
@@ -392,7 +391,6 @@ Some variables may require a special value format.
# Core variables
[core]
- uri = https://github.com/theory/sqitch/
engine = pg
db = widgetopolis
top_dir = migrations
@@ -414,14 +412,6 @@ appropriate manual page.
=over
-=item C<core.uri>
-
-A uniform resource identifier that uniquely identifies the project. Used to
-generate unique IDs for project changes, and so should be consistently used in
-the project, but not shared across projects. Thus it is recommended to always
-be used in the local configuration file, but not the user or system
-configuration files.
-
=item C<core.plan_file>
The plan file to use. Defaults to F<$top_dir/sqitch.plan>.
View
9 lib/sqitch.pod
@@ -225,15 +225,6 @@ engines.
Port number to connect to. Does not apply to all engines.
-=item C<--uri>
-
- sqitch --uri https://github.com/theory/sqitch/
-
-A uniform resource identifier that uniquely identifies the project. Used to
-generate unique IDs for project changes, and so should be consistently used in
-the project. Thus it it is probably best set as a local configuration setting
-(C<core.uri>).
-
=item C<--top-dir>
sqitch --top-dir migrations/
View
1  lib/sqitchtutorial.pod
@@ -49,7 +49,6 @@ when we initialize Sqitch:
Let's have a look at F<sqitch.conf>:
[core]
- uri = https://github.com/theory/sqitch-intro/
engine = pg
# plan_file = sqitch.plan
# top_dir = .
View
2  t/add.t
@@ -14,14 +14,12 @@ use Test::Dir;
use Test::File qw(file_not_exists_ok file_exists_ok);
use Test::File::Contents;
use File::Path qw(make_path remove_tree);
-use URI;
use lib 't/lib';
use MockOutput;
my $CLASS = 'App::Sqitch::Command::add';
ok my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
top_dir => Path::Class::Dir->new('sql'),
), 'Load a sqitch sqitch object';
my $config = $sqitch->config;
View
11 t/base.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 90;
+use Test::More tests => 86;
#use Test::More 'no_plan';
use Test::MockModule;
use Path::Class;
@@ -65,13 +65,6 @@ is $sqitch->deploy_dir, dir(qw(deploy)), 'Default deploy_dir should be ./sql/dep
is $sqitch->revert_dir, dir(qw(revert)), 'Default revert_dir should be ./sql/revert';
is $sqitch->test_dir, dir(qw(test)), 'Default test_dir should be ./sql/test';
isa_ok $sqitch->plan, 'App::Sqitch::Plan';
-throws_ok { $sqitch->uri } 'App::Sqitch::X',
- 'Should get error for missing URI';
-is $@->ident, 'core', 'Should be a "core" exception';
-is $@->message, __x(
- 'Missing project URI. Run {command} to add a URI',
- command => '`sqitch config core.uri URI`'
-), 'Should have localized error message about missing URI';
is $sqitch->user_name, do {
require User::pwent;
(User::pwent::getpwnam(getlogin)->gecos)[0];
@@ -125,8 +118,6 @@ GO: {
'Should have local config overriding user';
is $config->get(key => 'core.pg.host'), 'localhost',
'Should fall back on user config';
- is $sqitch->uri, URI->new('https://github.com/theory/sqitch/'),
- 'Should read URI from config file';
is $sqitch->user_name, 'Michael Stonebraker',
'Should have read user name from configuration';
is $sqitch->user_email, 'michael@example.com',
View
3  t/change.t
@@ -16,7 +16,6 @@ use Path::Class;
use File::Path qw(make_path remove_tree);
use Digest::SHA1;
use Test::MockModule;
-use URI;
my $CLASS;
@@ -53,7 +52,6 @@ can_ok $CLASS, qw(
);
my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
top_dir => dir('sql'),
);
my $plan = App::Sqitch::Plan->new(sqitch => $sqitch);
@@ -239,7 +237,6 @@ is $fh->getline, "-- test it, baby\n", 'It should be the test file';
# Test the requires/conflicts params.
my $file = file qw(t plans multi.plan);
my $sqitch2 = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
top_dir => dir('sql'),
plan_file => $file,
);
View
5 t/changelist.t
@@ -11,13 +11,10 @@ use Test::Exception;
use App::Sqitch;
use App::Sqitch::Plan;
use Locale::TextDomain qw(App-Sqitch);
-use URI;
BEGIN { require_ok 'App::Sqitch::Plan::ChangeList' or die }
-my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
-);
+my $sqitch = App::Sqitch->new;
my $plan = App::Sqitch::Plan->new(sqitch => $sqitch);
my $foo = App::Sqitch::Plan::Change->new(plan => $plan, name => 'foo');
View
8 t/engine.t
@@ -14,7 +14,6 @@ use Test::NoWarnings;
use Test::MockModule;
use Locale::TextDomain qw(App-Sqitch);
use App::Sqitch::X qw(hurl);
-use URI;
use lib 't/lib';
use MockOutput;
@@ -77,8 +76,7 @@ ENGINE: {
sub name_for_change_id { return 'bugaboo' }
}
-my $uri = URI->new('https://github.com/theory/sqitch/');
-ok my $sqitch = App::Sqitch->new(db_name => 'mydb', uri => $uri),
+ok my $sqitch = App::Sqitch->new(db_name => 'mydb'),
'Load a sqitch sqitch object';
##############################################################################
@@ -232,7 +230,7 @@ $record_work = 0;
chdir 't';
my $plan_file = file qw(sql sqitch.plan);
my $sqitch_old = $sqitch; # Hang on to this because $change does not retain it.
-$sqitch = App::Sqitch->new( plan_file => $plan_file, uri => $uri );
+$sqitch = App::Sqitch->new( plan_file => $plan_file );
ok $engine = App::Sqitch::Engine::whu->new( sqitch => $sqitch ),
'Engine with sqitch with plan file';
my $plan = $sqitch->plan;
@@ -443,7 +441,7 @@ NOSTEPS: {
say $fh '%project=empty';
$fh->close or die "Error closing $plan_file: $!";
END { $plan_file->remove }
- my $sqitch = App::Sqitch->new( plan_file => $plan_file, uri => $uri );
+ my $sqitch = App::Sqitch->new( plan_file => $plan_file );
ok $engine = App::Sqitch::Engine::whu->new( sqitch => $sqitch ),
'Engine with sqitch with no file';
throws_ok { $engine->deploy } 'App::Sqitch::X', 'Should die with no changes';
View
10 t/init.t
@@ -139,15 +139,12 @@ file_contents_like $conf_file, qr{\Q[core]
unlink $conf_file;
# Set two options.
-$sqitch = App::Sqitch->new(
- extension => 'foo',
- uri => URI->new('https://github.com/theory/sqitch/'),
-);
+$sqitch = App::Sqitch->new( extension => 'foo' );
ok $init = $CLASS->new(sqitch => $sqitch), 'Another init object';
ok $init->write_config, 'Write the config';
file_exists_ok $conf_file;
is_deeply read_config $conf_file, {
- 'core.uri' => 'https://github.com/theory/sqitch/',
+ 'core.uri' => $uri,
'core.extension' => 'foo',
}, 'The configuration should have been written with the two settings';
is_deeply +MockOutput->get_info, [
@@ -166,7 +163,7 @@ file_contents_like $conf_file, qr{
# Go again.
ok $init->write_config, 'Write the config again';
is_deeply read_config $conf_file, {
- 'core.uri' => 'https://github.com/theory/sqitch/',
+ 'core.uri' => $uri,
'core.extension' => 'foo',
}, 'The configuration should be unchanged';
is_deeply +MockOutput->get_info, [
@@ -211,7 +208,6 @@ SYSTEMCONF: {
'core.uri' => $uri,
'core.extension' => 'foo',
'core.engine' => 'pg',
- 'core.uri' => URI->new('https://github.com/theory/sqitch/'),
}, 'The configuration should have local and system config';
is_deeply +MockOutput->get_info, [
[__x 'Created {file}', file => $conf_file]
View
3  t/log.t
@@ -12,16 +12,13 @@ use Test::Exception;
use Test::MockModule;
use Path::Class;
use Term::ANSIColor qw(color);
-use URI;
use lib 't/lib';
use MockOutput;
my $CLASS = 'App::Sqitch::Command::log';
require_ok $CLASS;
-my $uri = URI->new('https://github.com/theory/sqitch/');
ok my $sqitch = App::Sqitch->new(
- uri => $uri,
top_dir => Path::Class::Dir->new('sql'),
_engine => 'sqlite',
), 'Load a sqitch sqitch object';
View
7 t/options.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
use utf8;
-use Test::More tests => 25;
+use Test::More tests => 24;
#use Test::More 'no_plan';
use Test::MockModule;
use Capture::Tiny ':all';
@@ -97,7 +97,6 @@ my $opts = $CLASS->_parse_core_opts([
'--revert-dir' => 'rev',
'--test-dir' => 'tst',
'--extension' => 'ext',
- '--uri' => 'https://github.com/theory/sqitch/',
'--verbose', '--verbose',
'--quiet'
]);
@@ -115,14 +114,10 @@ is_deeply $opts, {
'revert_dir' => 'rev',
'test_dir' => 'tst',
'extension' => 'ext',
- 'uri' => 'https://github.com/theory/sqitch/',
verbosity => 2,
quiet => 1,
}, 'Should parse lots of options';
-# Make sure objects are created.
-isa_ok $opts->{uri}, 'URI', 'URI option';
-
for my $dir (qw(top_dir deploy_dir revert_dir test_dir)) {
isa_ok $opts->{$dir}, 'Path::Class::Dir', $dir;
}
View
7 t/pg.t
@@ -11,7 +11,6 @@ use Capture::Tiny qw(:all);
use Try::Tiny;
use App::Sqitch;
use App::Sqitch::Plan;
-use URI;
my $CLASS;
@@ -32,9 +31,7 @@ is_deeply [$CLASS->config_vars], [
sqitch_schema => 'any',
], 'config_vars should return three vars';
-my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
-);
+my $sqitch = App::Sqitch->new;
isa_ok my $pg = $CLASS->new(sqitch => $sqitch), $CLASS;
my $client = 'psql' . ($^O eq 'Win32' ? '.exe' : '');
@@ -120,7 +117,6 @@ $sqitch = App::Sqitch->new(
db_name => 'widgets_dev',
db_host => 'foo.com',
db_port => 98760,
- uri => URI->new('https://github.com/theory/sqitch/'),
);
ok $pg = $CLASS->new(sqitch => $sqitch), 'Create a pg with sqitch with options';
@@ -249,7 +245,6 @@ subtest 'live database' => sub {
db_username => 'postgres',
top_dir => Path::Class::dir(qw(t pg)),
plan_file => Path::Class::file(qw(t pg sqitch.plan)),
- uri => URI->new('https://github.com/theory/sqitch/'),
);
my $user1_name = 'Marge Simpson';
my $user1_email = 'marge@example.com';
View
25 t/plan.t
@@ -15,7 +15,6 @@ use Test::File::Contents;
use Encode;
#use Test::NoWarnings;
use File::Path qw(make_path remove_tree);
-use URI;
use lib 't/lib';
use MockOutput;
@@ -31,13 +30,15 @@ can_ok $CLASS, qw(
changes
position
load
+ syntax_version
+ project
+ uri
_parse
sort_changes
open_script
);
-my $uri = URI->new('https://github.com/theory/sqitch/');
-my $sqitch = App::Sqitch->new(uri => $uri);
+my $sqitch = App::Sqitch->new;
isa_ok my $plan = App::Sqitch::Plan->new(sqitch => $sqitch), $CLASS;
# Set up some some utility functions for creating changes.
@@ -545,6 +546,7 @@ cmp_deeply delete $parsed->{pragmas}, {
syntax_version => App::Sqitch::Plan::SYNTAX_VERSION,
foo => 'bar',
project => 'pragmata',
+ uri => 'https://github.com/theory/sqitch/',
strict => 1,
}, 'Should have captured all of the pragmas';
cmp_deeply { map { $_ => [$parsed->{$_}->items] } keys %{ $parsed } }, {
@@ -558,6 +560,7 @@ cmp_deeply { map { $_ => [$parsed->{$_}->items] } keys %{ $parsed } }, {
prag( '', ' ', 'syntax-version', '', '=', '', App::Sqitch::Plan::SYNTAX_VERSION),
prag( ' ', '', 'foo', ' ', '=', ' ', 'bar', ' ', 'lolz'),
prag( '', ' ', 'project', '', '=', '', 'pragmata'),
+ prag( '', ' ', 'uri', '', '=', '', 'https://github.com/theory/sqitch/'),
blank(),
change { name => 'hey' },
change { name => 'you' },
@@ -619,7 +622,7 @@ cmp_deeply { map { $_ => [$parsed->{$_}->items] } keys %{ $parsed } }, {
# Try a non-existent plan file with load().
$file = file qw(t hi nonexistent.plan);
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri);
+$sqitch = App::Sqitch->new(plan_file => $file);
throws_ok { App::Sqitch::Plan->new(sqitch => $sqitch)->load } 'App::Sqitch::X',
'Should get exception for nonexistent plan file';
is $@->ident, 'plan', 'Nonexistent plan file ident should be "plan"';
@@ -630,7 +633,7 @@ is $@->message, __x(
# Try a plan with dependencies.
$file = file qw(t plans dependencies.plan);
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri);
+$sqitch = App::Sqitch->new(plan_file => $file);
isa_ok $plan = App::Sqitch::Plan->new(sqitch => $sqitch), $CLASS,
'Plan with sqitch with plan file with dependencies';
ok $parsed = $plan->load, 'Load plan with dependencies file';
@@ -656,7 +659,7 @@ is sorted, 2, 'Should have sorted changes twice';
# Should fail with dependencies on tags.
$file = file qw(t plans tag_dependencies.plan);
$fh = IO::File->new(\"foo $tsnp\n\@bar [:foo] $tsnp", '<:utf8');
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri);
+$sqitch = App::Sqitch->new(plan_file => $file);
isa_ok $plan = App::Sqitch::Plan->new(sqitch => $sqitch), $CLASS,
'Plan with sqitch with plan with tag dependencies';
throws_ok { $plan->_parse($file, $fh) } 'App::Sqitch::X',
@@ -671,7 +674,7 @@ is $@->message, __x(
# Make sure that lines() loads the plan.
$file = file qw(t plans multi.plan);
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri);
+$sqitch = App::Sqitch->new(plan_file => $file);
isa_ok $plan = App::Sqitch::Plan->new(sqitch => $sqitch), $CLASS,
'Plan with sqitch with plan file';
cmp_deeply [$plan->lines], [
@@ -1194,7 +1197,7 @@ is $@->message, __x(
##############################################################################
# Try a plan with a duplicate change in different tag sections.
$file = file qw(t plans dupe-change-diff-tag.plan);
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri);
+$sqitch = App::Sqitch->new(plan_file => $file);
isa_ok $plan = App::Sqitch::Plan->new(sqitch => $sqitch), $CLASS,
'Plan shoud work plan with dupe change across tags';
cmp_deeply [ $plan->lines ], [
@@ -1441,13 +1444,17 @@ for my $req (qw(wanker @blah greets@foo)) {
##############################################################################
# Test pragma accessors.
+is $plan->uri, undef, 'Should have undef URI when no pragma';
$file = file qw(t plans pragmas.plan);
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri);
+$sqitch = App::Sqitch->new(plan_file => $file);
isa_ok $plan = App::Sqitch::Plan->new(sqitch => $sqitch), $CLASS,
'Plan with sqitch with plan file with dependencies';
is $plan->syntax_version, App::Sqitch::Plan::SYNTAX_VERSION,
'syntax_version should be set';
is $plan->project, 'pragmata', 'Project should be set';
+is $plan->uri, URI->new('https://github.com/theory/sqitch/'),
+ 'Should have URI from pragma';
+isa_ok $plan->uri, 'URI', 'It';
# Make sure we get an error if there is no project pragma.
$fh = IO::File->new(\"foo $tsnp", '<:utf8');
View
1  t/plans/pragmas.plan
@@ -1,6 +1,7 @@
% syntax-version=1.0.0
%foo = bar # lolz
% project=pragmata
+% uri=https://github.com/theory/sqitch/
hey 2012-07-16T17:25:07Z Barack Obama <potus@whitehouse.gov>
you 2012-07-16T17:25:07Z Barack Obama <potus@whitehouse.gov>
View
2  t/rework.t
@@ -9,7 +9,6 @@ use App::Sqitch;
use Locale::TextDomain qw(App-Sqitch);
use Test::NoWarnings;
use Test::Exception;
-use URI;
use App::Sqitch::Command::add;
use Path::Class;
use Test::File qw(file_not_exists_ok file_exists_ok);
@@ -21,7 +20,6 @@ use MockOutput;
my $CLASS = 'App::Sqitch::Command::rework';
ok my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
top_dir => Path::Class::Dir->new('sql'),
), 'Load a sqitch sqitch object';
my $config = $sqitch->config;
View
7 t/status.t
@@ -11,16 +11,13 @@ use Test::NoWarnings;
use Test::Exception;
use Test::MockModule;
use Path::Class;
-use URI;
use lib 't/lib';
use MockOutput;
my $CLASS = 'App::Sqitch::Command::status';
require_ok $CLASS;
-my $uri = URI->new('https://github.com/theory/sqitch/');
ok my $sqitch = App::Sqitch->new(
- uri => $uri,
top_dir => Path::Class::Dir->new('sql'),
), 'Load a sqitch sqitch object';
my $config = $sqitch->config;
@@ -141,7 +138,7 @@ $engine_mocker->mock(current_changes => sub { sub { shift @current_changes } });
planner_email => 'anna@example.com',
planned_at => $dt->clone->subtract( hours => 4 ),
});
-$sqitch = App::Sqitch->new(uri => $uri, _engine => 'sqlite');
+$sqitch = App::Sqitch->new(_engine => 'sqlite');
ok $status = App::Sqitch::Command->load({
sqitch => $sqitch,
command => 'status',
@@ -291,7 +288,7 @@ is_deeply +MockOutput->get_comment, [
##############################################################################
# Test emit_status().
my $file = file qw(t plans multi.plan);
-$sqitch = App::Sqitch->new(plan_file => $file, uri => $uri, _engine => 'sqlite');
+$sqitch = App::Sqitch->new(plan_file => $file, _engine => 'sqlite');
my @changes = $sqitch->plan->changes;
ok $status = App::Sqitch::Command->load({
sqitch => $sqitch,
View
5 t/tag.t
@@ -11,7 +11,6 @@ use App::Sqitch;
use App::Sqitch::Plan;
use Test::MockModule;
use Digest::SHA1;
-use URI;
my $CLASS;
@@ -36,9 +35,7 @@ can_ok $CLASS, qw(
format_planner
);
-my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
-);
+my $sqitch = App::Sqitch->new;
my $plan = App::Sqitch::Plan->new(sqitch => $sqitch);
my $change = App::Sqitch::Plan::Change->new( plan => $plan, name => 'roles' );
View
2  t/tag_cmd.t
@@ -9,14 +9,12 @@ use App::Sqitch;
use Locale::TextDomain qw(App-Sqitch);
use Test::NoWarnings;
use File::Path qw(make_path remove_tree);
-use URI;
use lib 't/lib';
use MockOutput;
my $CLASS = 'App::Sqitch::Command::tag';
ok my $sqitch = App::Sqitch->new(
- uri => URI->new('https://github.com/theory/sqitch/'),
top_dir => Path::Class::Dir->new('sql'),
), 'Load a sqitch sqitch object';
my $config = $sqitch->config;

No commit comments for this range

Something went wrong with that request. Please try again.