0

レガシー コードベースに適用するパッチがあります。is thereという名前のファイルがたくさんありますpom.xmlが、変更をスキップする必要があります。それらをパッチから削除するにはどうすればよいですか?

sed '/^diff --git .*pom.xml$/,/^diff --git/d'

最後に余分な行を 1 行削除します (これは、以降の処理に必要です)。

おそらく、最初のパターンを含み、2 番目のパターンを除く 2 つのパターン間の行を削除するソリューションが必要です。私は MSYS に限定されているため、Windows コマンドの sed と mawk のみにアクセスできます。

以下は入力例です。そこには 3 つのエントリがあり、2 番目のエントリは削除されます。

diff --git a/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF b/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF
index a02c3f0..b74197f 100644
--- a/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF
+++ b/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF
@@ -2,13 +2,13 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Q7 Debug
 Bundle-SymbolicName: org.eclipse.rcptt.ctx.debug;singleton:=true
-Bundle-Version: 1.5.0.qualifier
+Bundle-Version: 1.5.3.qualifier
 Bundle-ClassPath: .
 Bundle-Vendor: Eclipse RCP Testing Tool Project
 Bundle-Localization: plugin
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.rcptt.core;bundle-version="[1.5.0,1.6.0)";visibility:=reexport
+ org.eclipse.rcptt.core;bundle-version="[1.5.3,1.6.0)";visibility:=reexport
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.rcptt.debug,
  org.eclipse.rcptt.debug.impl,
diff --git a/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml b/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml
index e12f814..e18b46a 100644
--- a/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml
+++ b/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml
@@ -4,10 +4,10 @@
   <parent>
     <artifactId>rcptt.core.contexts</artifactId>
     <groupId>org.eclipse.rcptt</groupId>
-    <version>1.5.0-SNAPSHOT</version>
+    <version>1.5.3-SNAPSHOT</version>
   </parent>
   <groupId>org.eclipse.rcptt</groupId>
   <artifactId>org.eclipse.rcptt.ctx.debug</artifactId>
-  <version>1.5.0-SNAPSHOT</version>
+  <version>1.5.3-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 </project>
diff --git a/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF b/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF
index 88ccb8b..b8c1308 100644
--- a/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF
+++ b/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Q7 Context Extensions
 Bundle-SymbolicName: org.eclipse.rcptt.ctx.extensions;singleton:=true
-Bundle-Version: 1.5.0.qualifier
+Bundle-Version: 1.5.3.qualifier
 Bundle-Activator: org.eclipse.rcptt.ctx.extensions.ContextExtensionsPlugin
 Bundle-Vendor: Eclipse RCP Testing Tool Project
 Require-Bundle: org.eclipse.core.runtime,

これまでに見つけたすべての解決策は、パターンのある開始行と末尾行の両方を削除するか、いずれも削除しません。

4

1 に答える 1

1

最後に、実用的なソリューション:

awk '
  /^diff --git/ {skip = 0}
  /^diff --git .*pom.xml$/ { skip = 1}
  {if (!skip) print $0}
' 

これは、おそらく sed の仕事ではありませんでした。

于 2014-09-25T09:27:22.000 に答える