From c44bbc41c44a97e2e598f542b9d96b145a1d28e0 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Fri, 19 Nov 2010 20:17:34 -0800 Subject: Filter version string off diff when comparing active/working to a file. --- scripts/vyatta-config-mgmt.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'scripts') diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl index 4516f79..ae4344d 100755 --- a/scripts/vyatta-config-mgmt.pl +++ b/scripts/vyatta-config-mgmt.pl @@ -91,6 +91,23 @@ sub parse_at_output { return (1, '', ''); } +sub filter_version_string { + my ($diff) = @_; + + my @lines = split("\n", $diff); + + my @new_lines = (); + my $found = 0; + while (my $line = pop(@lines)) { + if (! $found) { + $found = 1 if $line =~ /^@@/; + } else { + unshift(@new_lines, $line); + } + } + return join("\n", @new_lines); +} + # # main @@ -254,6 +271,7 @@ if ($action eq 'diff') { my $filename1 = cm_commit_get_file_name($rev1); my $diff = `zdiff -u $filename1 $tmp_config_file`; if (defined $diff and length($diff) > 0) { + $diff = filter_version_string($diff); print $diff; } else { print "No changes between working and " -- cgit v1.2.3