initGitWithTwoBranches initializes a git repository in dir with two branches: - "main" with models/model.sql = SELECT 'main' AS env - "staging" with models/model.sql = SELECT 'staging' AS env The repo is left checked out on the "staging" branch.
(t *testing.T, dir string)
| 478 | // - "staging" with models/model.sql = SELECT 'staging' AS env |
| 479 | // The repo is left checked out on the "staging" branch. |
| 480 | func initGitWithTwoBranches(t *testing.T, dir string) { |
| 481 | t.Helper() |
| 482 | runGitCmd := func(args ...string) { |
| 483 | cmd := exec.Command("git", args...) |
| 484 | cmd.Dir = dir |
| 485 | out, err := cmd.CombinedOutput() |
| 486 | require.NoError(t, err, "git %v failed: %s", args, out) |
| 487 | } |
| 488 | |
| 489 | runGitCmd("init", "-b", "main") |
| 490 | runGitCmd("config", "user.email", "test@rilldata.com") |
| 491 | runGitCmd("config", "user.name", "Rill Test User") |
| 492 | |
| 493 | // commit initial content on main |
| 494 | putFiles(t, dir, map[string]string{ |
| 495 | "models/model.sql": `SELECT 'main' AS env`, |
| 496 | }) |
| 497 | runGitCmd("add", ".") |
| 498 | runGitCmd("commit", "-m", "initial commit on main") |
| 499 | |
| 500 | // create staging branch with different content |
| 501 | runGitCmd("checkout", "-b", "staging") |
| 502 | putFiles(t, dir, map[string]string{ |
| 503 | "models/model.sql": `SELECT 'staging' AS env`, |
| 504 | }) |
| 505 | runGitCmd("add", ".") |
| 506 | runGitCmd("commit", "-m", "staging changes") |
| 507 | } |
| 508 | |
| 509 | func authGitURL(t *testing.T, repoURL, token string) string { |
| 510 | u, err := url.Parse(repoURL) |
no test coverage detected