Skip to content

Commit

Permalink
Item13759: Add way to group patches.
Browse files Browse the repository at this point in the history
List them in the ~~~PATCH record.
  • Loading branch information
gac410 committed Oct 6, 2015
1 parent 20d809a commit 9a10711
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions PatchFoswikiContrib/data/System/PatchFoswikiContrib.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1443830494" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1444094021" format="1.1" version="1"}%
<!--
One line description, required for extensions repository catalog.
* Set SHORTDESCRIPTION = File patch tool for Foswiki
Expand Down Expand Up @@ -38,12 +38,12 @@ version of a target file. The patch file consists of

$ _Summary_: A general description of the patch. It can be any number of lines long and will be reported in the installation log.
$ _Patch Target_: A single line used to specify exactly which file is to be patched. Identifies a single version of a patch along with the md5 of the target file, the filename and a comment.
<verbatim>~~~PATCH fdeeb7f236608b7792ad0845bf2279f9:76e28354522a6d6cccc76c66f99d2424 lib/Foswiki/Configure/Dependency.pm (Foswiki 1.1.5)</verbatim>
<verbatim>~~~PATCH fdeeb7f236608b7792ad0845bf2279f9:76e28354522a6d6cccc76c66f99d2424 lib/Foswiki/Configure/Dependency.pm (Foswiki-1.1.8,Foswiki-1.1.9)</verbatim>
* =~~~PATCH= Identifies this as a patch
* =fdee..79f9= is the 32 character MD5 hash of the original version of the unpatched target file. If this matches the file, the patch is eligible to be installed.
* =76e2..2424= is the 32 character MD5 hash of the patched version of the file. If tthis matches the file, the patch is already applied and could be removed.
* =lib/Foswiki...= The target file name
* =(Comment)= A comment in optional parenthesis, such as the foswiki version that shipped this file..
* =(Foswiki-1.1.8,Foswiki-1.1.9)= A comma separated list of releases that this patch covers.
$ _The patch_: A patch in unified diff format, such as: =diff -Naur oldversionFile newVersionFile=

---+++ Creating the patch file,
Expand Down
5 changes: 3 additions & 2 deletions PatchFoswikiContrib/lib/Foswiki/Configure/PatchFile.pm
Expand Up @@ -38,7 +38,7 @@ Supports two differnt patch file record layouts:
#~~~PATCH fdeeb7f236608b7792ad0845bf2279f9 lib/Foswiki/Configure/Dependency.pm (Foswiki-1.1.5)
#
# target file MD5 patched file MD5 relative file path RELEASE
#~~~PATCH fdeeb7f236608b7792ad0845bf2279f9:fdeeb7f236608b7792ad0845bf2279f9 lib/Foswiki/Configure/Dependency.pm (Foswiki-1.1.5)
#~~~PATCH fdeeb7f236608b7792ad0845bf2279f9:fdeeb7f236608b7792ad0845bf2279f9 lib/Foswiki/Configure/Dependency.pm (Foswiki-1.1.5,Foswiki-1.1.6)
</verbatim>
=cut
Expand Down Expand Up @@ -235,7 +235,8 @@ sub checkPatch {
: $origMD5 eq $patchRef->{$key}{$md5}{patched} ? 'PATCHED'
: 'N/A';
if ( $patchRef->{$key}{$md5}{version}
&& $patchRef->{$key}{$md5}{version} ne $Foswiki::RELEASE )
&& $patchRef->{$key}{$md5}{version} !~
m/\b\Q$Foswiki::RELEASE\E\b/ )
{
$match = "N/A Release";
}
Expand Down
Expand Up @@ -71,7 +71,7 @@ sub _PATCHREPORT {
Foswiki::Configure::PatchFile::checkPatch( undef, \%result );

next
unless ( $ret =~ m/\|\s\Q$Foswiki::RELEASE\E\s\|/
unless ( $ret =~ m/\b\Q$Foswiki::RELEASE\E\b/
|| $params->{_DEFAULT} eq 'all' );
$resp .= $ret;
}
Expand Down
Expand Up @@ -90,7 +90,7 @@ Date: Mon Nov 5 05:07:25 2012 +0000
Item11267: Don't use "HEAD" to detect pseudo install.
~~~PATCH 829239dd10279df7a8851299e5beeeb2:630427bf41c01c9428d1e8d0ad298690 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1)
~~~PATCH 829239dd10279df7a8851299e5beeeb2:630427bf41c01c9428d1e8d0ad298690 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1,Foobar-2)
--- lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm 2012-12-24 16:48:56.663587164 -0500
+++ lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.new 2012-12-24 16:50:22.478548551 -0500
@@ -14,9 +14,9 @@
Expand All @@ -109,7 +109,7 @@ Date: Mon Nov 5 05:07:25 2012 +0000
Item11267: Don't use "HEAD" to detect pseudo install.
~~~PATCH 630427bf41c01c9428d1e8d0ad298690:829239dd10279df7a8851299e5beeeb2 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1)
~~~PATCH 630427bf41c01c9428d1e8d0ad298690:829239dd10279df7a8851299e5beeeb2 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1,Foobar-2)
--- lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm 2012-12-24 16:48:56.663587164 -0500
+++ lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.new 2012-12-24 16:50:22.478548551 -0500
@@ -14,9 +14,9 @@
Expand All @@ -128,7 +128,7 @@ Date: Mon Nov 5 05:07:25 2012 +0000
Item11267: Don't use "HEAD" to detect pseudo install.
~~~PATCH 123427bf41c01c9428d1e8d0ad298690:123239dd10279df7a8851299e5beeeb2 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1)
~~~PATCH 123427bf41c01c9428d1e8d0ad298690:123239dd10279df7a8851299e5beeeb2 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1,Foobar-2)
--- lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm 2012-12-24 16:48:56.663587164 -0500
+++ lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.new 2012-12-24 16:50:22.478548551 -0500
@@ -14,9 +14,9 @@
Expand All @@ -145,16 +145,16 @@ DONE
Foswiki::Configure::PatchFile::backupTargets( undef, \%result, 0 );

# N/A Release - patch should not be backed up
$this->assert_matches( qr/\| N\/A Release \|/ms, $msgs );
$this->assert_matches( qr/\| Foobar-1 \|/ms, $msgs );
$this->assert_matches( qr/^No files backed up./ms, $msgs );
$this->assert_matches( qr/\| N\/A Release \|/ms, $msgs );
$this->assert_matches( qr/\| Foobar-1,Foobar-2 \|/ms, $msgs );
$this->assert_matches( qr/^No files backed up./ms, $msgs );

$Foswiki::RELEASE = 'Foobar-1';
$msgs = Foswiki::Configure::PatchFile::backupTargets( undef, \%result, 0 );

# NOT APPLIED patch should be backed up
$this->assert_matches( qr/\| NOT APPLIED \|/ms, $msgs );
$this->assert_matches( qr/\| Foobar-1 \|/ms, $msgs );
$this->assert_matches( qr/\| NOT APPLIED \|/ms, $msgs );
$this->assert_matches( qr/\| Foobar-1,Foobar-2 \|/ms, $msgs );
$this->assert_matches( qr/^Backed up target: .*PatchTestTarget.pm/ms,
$msgs );
$this->assert_matches( qr/^Backup Archived.*configure\/backup\/Item000/ms,
Expand Down Expand Up @@ -222,7 +222,7 @@ Date: Mon Nov 5 05:07:25 2012 +0000
~~~PATCH 829239dd10279df7a8851299e5beeeb2:630427bf41c01c9428d1e8d0ad298690 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1)
~~~PATCH 829239dd10279df7a8851299e5beeeb2:630427bf41c01c9428d1e8d0ad298690 lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm (Foobar-1,Foobar-2)
--- lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm 2012-12-24 16:48:56.663587164 -0500
+++ lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.new 2012-12-24 16:50:22.478548551 -0500
@@ -14,9 +14,9 @@
Expand Down Expand Up @@ -272,7 +272,7 @@ DONE
my $msgs = Foswiki::Configure::PatchFile::checkPatch( undef, \%result );

$this->assert_equals(
"| lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm | 829239dd10279df7a8851299e5beeeb2 | NOT APPLIED | Foobar-1 |\n\n",
"| lib/Foswiki/Contrib/PatchFoswikiContrib/PatchTestTarget.pm | 829239dd10279df7a8851299e5beeeb2 | NOT APPLIED | Foobar-1,Foobar-2 |\n\n",
$msgs
);

Expand Down

0 comments on commit 9a10711

Please sign in to comment.