Name

App::Sqitch::Plan::Change - Sqitch deployment plan tag

Synopsis

  my $plan = App::Sqitch::Plan->new( sqitch => $sqitch );
  for my $line ($plan->lines) {
      say $line->as_string;
  }

Description

A App::Sqitch::Plan::Change represents a change as parsed from a plan file. In addition to the interface inherited from App::Sqitch::Plan::Line, it offers interfaces for parsing dependencies from the deploy script, as well as for opening the deploy, revert, and verify scripts.

Interface

See App::Sqitch::Plan::Line for the basics.

Accessors

since_tag

An App::Sqitch::Plan::Tag object representing the last tag to appear in the plan before the change. May be undef.

pspace

Blank space separating the change name from the dependencies, timestamp, and planner in the file.

is_reworked

Boolean indicting whether or not the change has been reworked.

info

Information about the change, returned as a string. Includes the change ID, the name and email address of the user who added the change to the plan, and the timestamp for when the change was added to the plan.

id

A SHA1 hash of the data returned by info(), which can be used as a globally-unique identifier for the change.

timestamp

Returns the an App::Sqitch::DateTime object representing the time at which the change was added to the plan.

planner_name

Returns the name of the user who added the change to the plan.

planner_email

Returns the email address of the user who added the change to the plan.

parent

Parent change object.

tags

A list of tag objects associated with the change.

Instance Methods

path_segments

  my @segments = $change->path_segments;

Returns the path segment for the change. For example, if the change is named "foo", ('foo.sql') is returned. If the change is named "functions/bar> ('functions', 'bar.sql') is returned. Internally, this data is used to create the deploy, revert, and verify file names.

deploy_dir

  my $file = $change->deploy_dir;

Returns the path to the deploy directory for the change.

deploy_file

  my $file = $change->deploy_file;

Returns the path to the deploy script file for the change.

revert_dir

  my $file = $change->revert_dir;

Returns the path to the revert directory for the change.

revert_file

  my $file = $change->revert_file;

Returns the path to the revert script file for the change.

verify_dir

  my $file = $change->verify_dir;

Returns the path to the verify directory for the change.

verify_file

  my $file = $change->verify_file;

Returns the path to the verify script file for the change.

script_file

  my $file = $sqitch->script_file($script_name);

Returns the path to a script, for the change.

script_hash

  my $hash = $change->script_hash;

Returns the hex digest of the SHA-1 hash for the deploy script.

rework_tags

  my @tags = $change->rework_tags;

Returns a list of tags that occur between a change and its next reworking. Returns an empty list if the change is not reworked.

add_tag

  $change->add_tag($tag);

Adds a tag object to the change.

add_rework_tags

  $change->add_rework_tags(@tags);

Adds tags to the list of rework tags.

clear_rework_tags

  $change->clear_rework_tags(@tags);

Clears the list of rework tags.

requires

  my @requires = $change->requires;

Returns a list of App::Sqitch::Plan::Depend objects representing changes required by this change.

requires_changes

  my @requires_changes = $change->requires_changes;

Returns a list of the App::Sqitch::Plan::Change objects representing changes required by this change.

conflicts

  my @conflicts = $change->conflicts;

Returns a list of App::Sqitch::Plan::Depend objects representing changes with which this change conflicts.

conflicts_changes

  my @conflicts_changes = $change->conflicts_changes;

Returns a list of the App::Sqitch::Plan::Change objects representing changes with which this change conflicts.

dependencies

  my @dependencies = $change->dependencies;

Returns a list of App::Sqitch::Plan::Depend objects representing all dependencies, required and conflicting.

is_deploy

Returns true if the change is intended to be deployed, and false if it should be reverted.

is_revert

Returns true if the change is intended to be reverted, and false if it should be deployed.

action

Returns "deploy" if the change should be deployed, or "revert" if it should be reverted.

format_tag_qualified_name

  my $tag_qualified_name = $change->format_tag_qualified_name;

Returns a string with the change name followed by the next tag in the plan. Useful for displaying unambiguous change specifications for reworked changes. If there is no tag appearing in the file after the change, the @HEAD will be used.

format_name_with_tags

  my $name_with_tags = $change->format_name_with_tags;

Returns a string formatted with the change name followed by the list of tags, if any, associated with the change. Used to display a change as it is deployed.

format_dependencies

  my $dependencies = $change->format_dependencies;

Returns a string containing a bracketed list of dependencies. If there are no dependencies, an empty string will be returned.

format_name_with_dependencies

  my $name_with_dependencies = $change->format_name_with_dependencies;

Returns a string formatted with the change name followed by a bracketed list of dependencies, if any, associated with the change. Used to display a change when added to a plan.

format_op_name_dependencies

  my $op_name_dependencies = $change->format_op_name_dependencies;

Like format_name_with_dependencies, but includes the operator, if present.

format_planner

  my $planner = $change->format_planner;

Returns a string formatted with the name and email address of the user who added the change to the plan.

deploy_handle

  my $fh = $change->deploy_handle;

Returns an IO::File file handle, opened for reading, for the deploy script for the change.

revert_handle

  my $fh = $change->revert_handle;

Returns an IO::File file handle, opened for reading, for the revert script for the change.

verify_handle

  my $fh = $change->verify_handle;

Returns an IO::File file handle, opened for reading, for the verify script for the change.

note_prompt

  my $prompt = $change->note_prompt(
      for     => 'rework',
      scripts => [$change->deploy_file, $change->revert_file],
  );

Overrides the implementation from App::Sqitch::Plan::Line to add the files parameter. This is a list of the files to be created for the command. These will usually be the deploy, revert, and verify files, but the caller might not be creating all of them, so it needs to pass the list.

See Also

App::Sqitch::Plan

Class representing a plan.

App::Sqitch::Plan::Line

Base class from which App::Sqitch::Plan::Change inherits.

sqitch

The Sqitch command-line client.

Author

David E. Wheeler <david@justatheory.com>

License

Copyright (c) 2012-2024 iovation Inc., David E. Wheeler

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.