Commit 5591a21e authored by Mustafa Gezen's avatar Mustafa Gezen 🏗
Browse files

support patches that create new files

parent 11ad88bf
......@@ -266,7 +266,7 @@ func ProcessRPM(pd *ProcessData) {
srcPath = filepath.Join("SOURCES", patchedFile.NewName)
}
var output bytes.Buffer
if !patchedFile.IsDelete {
if !patchedFile.IsDelete && !patchedFile.IsNew {
patchSubjectFile, err := w.Filesystem.Open(srcPath)
if err != nil {
log.Fatalf("could not open patch subject: %v", err)
......@@ -282,7 +282,21 @@ func ProcessRPM(pd *ProcessData) {
_ = w.Filesystem.Remove(oldName)
_ = w.Filesystem.Remove(srcPath)
if !patchedFile.IsDelete {
if patchedFile.IsNew {
newFile, err := w.Filesystem.Create(srcPath)
if err != nil {
log.Fatalf("could not create new file: %v", err)
}
_, err = newFile.Write(output.Bytes())
if err != nil {
log.Fatalf("could not write post-patch file: %v", err)
}
_, err = w.Add(srcPath)
if err != nil {
log.Fatalf("could not add file %s to git: %v", srcPath, err)
}
log.Printf("git add %s", srcPath)
} else if !patchedFile.IsDelete {
newFile, err := w.Filesystem.Create(srcPath)
if err != nil {
log.Fatalf("could not create post-patch file: %v", err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment