Fix "move patch into new commit" for partial hunk (#2507)

This commit is contained in:
Stefan Haller 2023-03-18 08:17:47 +01:00 committed by GitHub
parent 81ea3107ed
commit 4b4dccfd7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 534 additions and 44 deletions

View file

@ -94,6 +94,16 @@ func (self *Shell) CreateFile(path string, content string) *Shell {
return self
}
func (self *Shell) DeleteFile(path string) *Shell {
fullPath := filepath.Join(self.dir, path)
err := os.Remove(fullPath)
if err != nil {
self.fail(fmt.Sprintf("error deleting file: %s\n%s", fullPath, err))
}
return self
}
func (self *Shell) CreateDir(path string) *Shell {
fullPath := filepath.Join(self.dir, path)
if err := os.MkdirAll(fullPath, 0o755); err != nil {
@ -171,6 +181,13 @@ func (self *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell
GitAdd(fileName)
}
// convenience method for deleting a file and adding it
func (self *Shell) DeleteFileAndAdd(fileName string) *Shell {
return self.
DeleteFile(fileName).
GitAdd(fileName)
}
// creates commits 01, 02, 03, ..., n with a new file in each
// The reason for padding with zeroes is so that it's easier to do string
// matches on the commit messages when there are many of them