forked from sosedoff/gitkit
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from aryan9600/master
Fix texts on Linux by setting git config vars
- Loading branch information
Showing
1 changed file
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ limitations under the License. | |
package gitkit | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
"net" | ||
"os" | ||
|
@@ -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 | ||
} | ||
|