mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-14 18:18:55 -06:00
dolt/{bats,go}: git dolt errors on unknown commands
This commit is contained in:
@@ -59,6 +59,12 @@ teardown() {
|
||||
[[ "$output" =~ "It looks like Dolt is not installed on your system" ]]
|
||||
}
|
||||
|
||||
@test "git dolt errors on unknown commands" {
|
||||
run git dolt nonsense
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Unknown command" ]] || false
|
||||
}
|
||||
|
||||
@test "git dolt prints usage information with no arguments" {
|
||||
run git dolt
|
||||
[[ "$output" =~ Usage ]] || false
|
||||
|
||||
@@ -27,31 +27,38 @@ func main() {
|
||||
|
||||
if cmd == "link" {
|
||||
remote := os.Args[2]
|
||||
dirname := lastSegment(remote)
|
||||
_, err := exec.Command("dolt", "clone", remote, "--insecure").Output()
|
||||
check(err)
|
||||
|
||||
revision := currentRevision(dirname)
|
||||
|
||||
ptrFile, err := os.Create(fmt.Sprintf("%s.git-dolt", dirname))
|
||||
check(err)
|
||||
defer ptrFile.Close()
|
||||
|
||||
_, err = ptrFile.WriteString(fmt.Sprintf("version %d\nremote %s\nrevision %s\n", gitDoltVersion, remote, revision))
|
||||
check(err)
|
||||
|
||||
giFile, err := os.OpenFile(".gitignore", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
|
||||
check(err)
|
||||
defer giFile.Close()
|
||||
|
||||
_, err = giFile.WriteString(fmt.Sprintf("%s\n", dirname))
|
||||
check(err)
|
||||
|
||||
fmt.Printf("\nSuccess!\n\n")
|
||||
fmt.Printf("* Dolt repository cloned to %s at revision %s\n", dirname, revision)
|
||||
fmt.Printf("* Pointer file created at %s.git-dolt\n", dirname)
|
||||
fmt.Printf("* %s added to .gitignore\n\nYou should git commit these results.\n", dirname)
|
||||
link(remote)
|
||||
return
|
||||
}
|
||||
|
||||
die("Unknown command " + cmd)
|
||||
}
|
||||
|
||||
func link(remote string) {
|
||||
dirname := lastSegment(remote)
|
||||
_, err := exec.Command("dolt", "clone", remote, "--insecure").Output()
|
||||
check(err)
|
||||
|
||||
revision := currentRevision(dirname)
|
||||
|
||||
ptrFile, err := os.Create(fmt.Sprintf("%s.git-dolt", dirname))
|
||||
check(err)
|
||||
defer ptrFile.Close()
|
||||
|
||||
_, err = ptrFile.WriteString(fmt.Sprintf("version %d\nremote %s\nrevision %s\n", gitDoltVersion, remote, revision))
|
||||
check(err)
|
||||
|
||||
giFile, err := os.OpenFile(".gitignore", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
|
||||
check(err)
|
||||
defer giFile.Close()
|
||||
|
||||
_, err = giFile.WriteString(fmt.Sprintf("%s\n", dirname))
|
||||
check(err)
|
||||
|
||||
fmt.Printf("\nSuccess!\n\n")
|
||||
fmt.Printf("* Dolt repository cloned to %s at revision %s\n", dirname, revision)
|
||||
fmt.Printf("* Pointer file created at %s.git-dolt\n", dirname)
|
||||
fmt.Printf("* %s added to .gitignore\n\nYou should git commit these results.\n", dirname)
|
||||
}
|
||||
|
||||
var hashRegex = regexp.MustCompile(`[0-9a-v]{32}`)
|
||||
|
||||
Reference in New Issue
Block a user