Use tmp branch with random name
This commit is contained in:
parent
ee1d741f4b
commit
0521e63f80
1 changed files with 11 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -38,7 +41,13 @@ func git(args ...string) {
|
|||
}
|
||||
|
||||
func exportCode(cmd *cobra.Command, args []string) {
|
||||
git("checkout", "-b", "temp")
|
||||
random := make([]byte, 4)
|
||||
if _, err := io.ReadFull(rand.Reader, random); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
tmpBranch := "temp/" + hex.EncodeToString(random)
|
||||
|
||||
git("checkout", "-b", tmpBranch)
|
||||
git("reset", "public")
|
||||
|
||||
privateFiles := listPrivateFiles(".")
|
||||
|
@ -50,7 +59,7 @@ func exportCode(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
git("checkout", "public")
|
||||
git("branch", "-D", "temp")
|
||||
git("branch", "-D", tmpBranch)
|
||||
|
||||
git("add", "-A")
|
||||
git("commit", "-m", "export public files", "--allow-empty")
|
||||
|
|
Loading…
Reference in a new issue