@@ -128,6 +128,13 @@ func (g *Generator) generateDoc() error {
128128 logrus .Errorf ("failed to generate CONTRIBUTORS on branch %s: %v" , newBranchName , err )
129129 }
130130
131+ // create a new branch named by input newBranchName
132+ // the following doc generation are all on this new branch
133+ cmd := exec .Command ("git" , "checkout" , "-b" , newBranchName )
134+ if data , err := cmd .CombinedOutput (); err != nil {
135+ return fmt .Errorf ("failed to git checkout -b %s: output(%s), err(%v)" , newBranchName , string (data ), err )
136+ }
137+
131138 // commit and push branch
132139 if err := g .gitCommitAndPush (newBranchName ); err != nil {
133140 if err == ErrNothingChanged {
@@ -170,12 +177,6 @@ func prepareGitEnv(newBranchName string) error {
170177 return fmt .Errorf ("failed to git push -f origin master: output(%s), err(%v)" , string (data ), err )
171178 }
172179
173- // create a new branch named by input newBranchName
174- // the following doc generation are all on this new branch
175- cmd = exec .Command ("git" , "checkout" , "-b" , newBranchName )
176- if data , err := cmd .CombinedOutput (); err != nil {
177- return fmt .Errorf ("failed to git checkout -b %s: output(%s), err(%v)" , newBranchName , string (data ), err )
178- }
179180 return nil
180181}
181182
@@ -211,16 +212,16 @@ func (g *Generator) gitCommitAndPush(newBranchName string) error {
211212 }
212213
213214 // git branch -D to delete branch to free resources.
214- cmd = exec .Command ("git" , "checkout" , "master" )
215- if data , err := cmd .CombinedOutput (); err != nil {
216- return fmt .Errorf ("failed to git checkout master before deleting branch %s: output(%s), err(%v)" , newBranchName , string (data ), err )
217- }
215+ // cmd = exec.Command("git", "checkout", "master")
216+ // if data, err := cmd.CombinedOutput(); err != nil {
217+ // return fmt.Errorf("failed to git checkout master before deleting branch %s: output(%s), err(%v)", newBranchName, string(data), err)
218+ // }
218219
219220 // git branch -D to delete branch to free resources.
220- cmd = exec .Command ("git" , "branch" , "-D" , newBranchName )
221- if data , err := cmd .CombinedOutput (); err != nil {
222- return fmt .Errorf ("failed to git push branch -D %s: output(%s), err(%v)" , newBranchName , string (data ), err )
223- }
221+ // cmd = exec.Command("git", "branch", "-D", newBranchName)
222+ // if data, err := cmd.CombinedOutput(); err != nil {
223+ // return fmt.Errorf("failed to git push branch -D %s: output(%s), err(%v)", newBranchName, string(data), err)
224+ // }
224225
225226 return nil
226227}
0 commit comments