#!/usr/bin/env bash
VERSION='v2.2.0'
perl -MNarada -E 'Narada::detect(@ARGV)' narada-1 || exit 1
# compatibility with Narada <1.2.0
[ -d ./var/patch/prev ] && mv ./var/patch/prev ./var/patch/.prev
exclude=( -x "\A./var/patch/" )
IFS=$'\n'
exclude+=( $(
(find ./config/ -type f; cd ./var/patch/.prev/; find ./config/ -type f) |
sort | uniq -c | grep '^ *2 ' | sed 's/^ *2 //' |
perl -ne 'chomp; print "-x\n"; print "\\A\Q$_\E\\z\n"'
) )
IFS=$' \t\n'
powerdiff -o tmp/CURRENT -f config/patch/exclude "${exclude[@]}" \
./var/patch/.prev/ ./
rm var/patch/CURRENT.* 2>/dev/null
mv tmp/CURRENT.pre.sh var/patch/CURRENT.10.sh 2>/dev/null
mv tmp/CURRENT.patch var/patch/CURRENT.20.patch 2>/dev/null
mv tmp/CURRENT.tgz var/patch/CURRENT.30.tgz 2>/dev/null
mv tmp/CURRENT.post.sh var/patch/CURRENT.40.sh 2>/dev/null
: <<'=cut'
=encoding utf8
=head1 NAME
narada-diff - prepare patch from previous version to current
=head1 VERSION
This document describes narada-diff version v2.2.0
=head1 USAGE
narada-diff
=head1 DESCRIPTION
Should be executed in Narada 1.x project root directory.
When executed, script will delete C<var/patch/CURRENT.*> files, then
detect all changes between previous and current project versions and
generate from 0 (if there are no changes) to 4 files with these names:
var/patch/CURRENT.10.sh
var/patch/CURRENT.20.patch
var/patch/CURRENT.30.tgz
var/patch/CURRENT.40.sh
You should review these files - if something is wrong, then make changes
to project and run C<narada-diff> again until you'll be happy.
Next you can manually modify these files. If you need to add some commands
to .sh files - it's better to put them into C<var/patch/PENDING.*.sh>
instead of modifying these files. But if you need to remove some changes
from these files to avoid including them into next update - it's ok.
Now, run C<narada-release> to release next update with all changes from
current C<var/patch/CURRENT.*> and C<var/patch/PENDING.*> files.
When detecting changes it take in account C<config/patch/exclude> plus
handle files in C<config/> in special way: only added and removed files
processed, changed files ignored.
=head1 CONFIGURATION AND ENVIRONMENT
Use config/patch/exclude.
Use files in var/patch/.
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker
at L<https://github.com/powerman/Narada/issues>.
You will be notified automatically of any progress on your issue.
=head2 Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
Feel free to fork the repository and submit pull requests.
L<https://github.com/powerman/Narada>
git clone https://github.com/powerman/Narada.git
=head2 Resources
=over
=item * MetaCPAN Search
L<https://metacpan.org/search?q=Narada>
=item * CPAN Ratings
L<http://cpanratings.perl.org/dist/Narada>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Narada>
=item * CPAN Testers Matrix
L<http://matrix.cpantesters.org/?dist=Narada>
=item * CPANTS: A CPAN Testing Service (Kwalitee)
L<http://cpants.cpanauthors.org/dist/Narada>
=back
=head1 AUTHOR
Alex Efros E<lt>powerman@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2008-2015 by Alex Efros E<lt>powerman@cpan.orgE<gt>.
This is free software, licensed under:
The MIT (X11) License
=cut