Skip to content

Commit ca7a16b

Browse files
committed
fix: stash empty commit
When the CreateCommit function in GitService creates a new branch, the dirty state of the repo will be cleaned and new all files disappear. Signed-off-by: Balazs Nadasdi <[email protected]>
1 parent 007d4f5 commit ca7a16b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stash/git.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ func (s *GitService) CreateCommit(rPath string, r *git.Repository, branchName st
256256
return nil, err
257257
}
258258

259+
if branchName != "" {
260+
err := s.CreateBranch(branchName, r, "")
261+
if err != nil {
262+
return nil, err
263+
}
264+
}
265+
259266
err = s.addCommitFiles(w, rPath, c.Files)
260267
if err != nil {
261268
return nil, err
@@ -268,13 +275,6 @@ func (s *GitService) CreateCommit(rPath string, r *git.Repository, branchName st
268275
c.Committer.Date = now
269276
}
270277

271-
if branchName != "" {
272-
err := s.CreateBranch(branchName, r, "")
273-
if err != nil {
274-
return nil, err
275-
}
276-
}
277-
278278
obj, err := s.commit(w, r, c)
279279
if err != nil {
280280
return nil, err

0 commit comments

Comments
 (0)