Skip to content

Commit

Permalink
backend: Add support for deleting dirs in GitHub CreateBranch (#3106)
Browse files Browse the repository at this point in the history
  • Loading branch information
septum committed Sep 3, 2024
1 parent 9998f12 commit 141939d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/service/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,20 @@ func (s *svc) CreateBranch(ctx context.Context, req *CreateBranchRequest) error
return err
}

for filename, contents := range req.Files {
for filePath, contents := range req.Files {
if contents == nil {
if err := wt.Filesystem.Remove(filename); err != nil {
if _, err := wt.Remove(filePath); err != nil {
return err
}
} else {
fh, err := wt.Filesystem.Create(filename)
fh, err := wt.Filesystem.Create(filePath)
if err != nil {
return err
}
if _, err := io.Copy(fh, contents); err != nil {
return err
}
if err := wt.AddWithOptions(&git.AddOptions{Path: filename}); err != nil {
if err := wt.AddWithOptions(&git.AddOptions{Path: filePath}); err != nil {
return err
}
}
Expand Down

0 comments on commit 141939d

Please sign in to comment.