Skip to content

Commit

Permalink
Merge pull request #4 from aryan9600/master
Browse files Browse the repository at this point in the history
Fix texts on Linux by setting git config vars
  • Loading branch information
pjbgf authored May 5, 2022
2 parents e1bf804 + c19f970 commit c056745
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package gitkit

import (
"fmt"
"math/rand"
"net"
"os"
Expand Down Expand Up @@ -131,27 +132,33 @@ func createRepo() (string, error) {
}

// init git
e := new(strings.Builder)
cmd := exec.Command("git", "init")
cmd.Dir = repo
cmd.Stderr = e
if _, err = cmd.Output(); err != nil {
return "", err
return "", fmt.Errorf("failed to initalize repo: %s", e.String())
}
e.Reset()

if err = os.WriteFile(filepath.Join(repo, "homework"), []byte("all done"), 0644); err != nil {
return "", err
}

cmd = exec.Command("git", "add", ".")
cmd.Dir = repo

cmd.Stderr = e
if _, err := cmd.Output(); err != nil {
return "", err
return "", fmt.Errorf("failed to add changes: %s", e.String())
}
e.Reset()

cmd = exec.Command("git", "commit", "-m", "add homework")
cmd = exec.Command("git", "-c", "[email protected]", "-c", "user.name=test-user", "commit", "-m", "add homework")
cmd.Dir = repo
cmd.Stderr = e

if _, err := cmd.Output(); err != nil {
return "", err
return "", fmt.Errorf("failed to commit changes: %s", e.String())
}
return repo, nil
}
Expand Down

0 comments on commit c056745

Please sign in to comment.