2014-06-05 23:13:42 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2014-09-29 16:52:24 +00:00
|
|
|
"path/filepath"
|
2014-06-05 23:13:42 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPushWithEmptyQueue(t *testing.T) {
|
|
|
|
repo := NewRepository(t, "empty")
|
|
|
|
defer repo.Test()
|
|
|
|
|
|
|
|
cmd := repo.Command("push")
|
|
|
|
cmd.Output = ""
|
|
|
|
}
|
2014-09-29 16:52:24 +00:00
|
|
|
|
|
|
|
func TestPushToMaster(t *testing.T) {
|
|
|
|
repo := NewRepository(t, "empty")
|
|
|
|
defer repo.Test()
|
|
|
|
|
|
|
|
cmd := repo.Command("push", "--dry-run", "origin", "master")
|
|
|
|
cmd.Output = "push a.dat"
|
|
|
|
|
|
|
|
cmd.Before(func() {
|
|
|
|
repo.GitCmd("remote", "remove", "origin")
|
|
|
|
|
|
|
|
originPath := filepath.Join(Root, "commands", "repos", "empty.git")
|
|
|
|
repo.GitCmd("remote", "add", "origin", originPath)
|
|
|
|
|
|
|
|
repo.GitCmd("fetch")
|
|
|
|
|
|
|
|
repo.WriteFile(filepath.Join(repo.Path, ".gitattributes"), "*.dat filter=media -crlf\n")
|
|
|
|
|
|
|
|
// Add a git media file
|
|
|
|
repo.WriteFile(filepath.Join(repo.Path, "a.dat"), "some data")
|
|
|
|
repo.GitCmd("add", "a.dat")
|
|
|
|
repo.GitCmd("commit", "-m", "a")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPushToNewBranch(t *testing.T) {
|
|
|
|
repo := NewRepository(t, "empty")
|
|
|
|
defer repo.Test()
|
|
|
|
|
2014-09-29 19:35:59 +00:00
|
|
|
cmd := repo.Command("push", "--dry-run", "origin", "newbranch")
|
2014-09-29 16:52:24 +00:00
|
|
|
cmd.Output = "push a.dat\npush b.dat"
|
|
|
|
|
|
|
|
cmd.Before(func() {
|
|
|
|
repo.GitCmd("remote", "remove", "origin")
|
|
|
|
|
|
|
|
originPath := filepath.Join(Root, "commands", "repos", "empty.git")
|
|
|
|
repo.GitCmd("remote", "add", "origin", originPath)
|
|
|
|
|
|
|
|
repo.GitCmd("fetch")
|
|
|
|
|
|
|
|
repo.WriteFile(filepath.Join(repo.Path, ".gitattributes"), "*.dat filter=media -crlf\n")
|
|
|
|
repo.GitCmd("add", ".gitattributes")
|
|
|
|
repo.GitCmd("commit", "-m", "attributes")
|
|
|
|
|
|
|
|
// Add a git media file
|
|
|
|
repo.WriteFile(filepath.Join(repo.Path, "a.dat"), "some data")
|
|
|
|
repo.GitCmd("add", "a.dat")
|
|
|
|
repo.GitCmd("commit", "-m", "a")
|
|
|
|
|
|
|
|
// Branch off
|
|
|
|
repo.GitCmd("checkout", "-b", "newbranch")
|
|
|
|
|
|
|
|
repo.WriteFile(filepath.Join(repo.Path, "b.dat"), "some more data")
|
|
|
|
repo.GitCmd("add", "b.dat")
|
|
|
|
repo.GitCmd("commit", "-m", "b")
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|