(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestCurrentRefAndCurrentRemoteRef(t *testing.T) { |
| 75 | repo := test.NewRepo(t) |
| 76 | repo.Pushd() |
| 77 | defer func() { |
| 78 | repo.Popd() |
| 79 | repo.Cleanup() |
| 80 | }() |
| 81 | |
| 82 | // test commits; we'll just modify the same file each time since we're |
| 83 | // only interested in branches |
| 84 | inputs := []*test.CommitInput{ |
| 85 | { // 0 |
| 86 | Files: []*test.FileInput{ |
| 87 | {Filename: "file1.txt", Size: 20}, |
| 88 | }, |
| 89 | }, |
| 90 | { // 1 |
| 91 | NewBranch: "branch2", |
| 92 | Files: []*test.FileInput{ |
| 93 | {Filename: "file1.txt", Size: 25}, |
| 94 | }, |
| 95 | }, |
| 96 | { // 2 |
| 97 | ParentBranches: []string{"master"}, // back on master |
| 98 | Files: []*test.FileInput{ |
| 99 | {Filename: "file1.txt", Size: 30}, |
| 100 | }, |
| 101 | }, |
| 102 | { // 3 |
| 103 | NewBranch: "branch3", |
| 104 | Files: []*test.FileInput{ |
| 105 | {Filename: "file1.txt", Size: 32}, |
| 106 | }, |
| 107 | }, |
| 108 | } |
| 109 | |
| 110 | outputs := repo.AddCommits(inputs) |
| 111 | |
| 112 | // last commit was on branch3 |
| 113 | gitConf := repo.GitConfig() |
| 114 | ref, err := CurrentRef() |
| 115 | assert.Nil(t, err) |
| 116 | assert.Equal(t, &Ref{ |
| 117 | Name: "branch3", |
| 118 | Type: RefTypeLocalBranch, |
| 119 | Sha: outputs[3].Sha, |
| 120 | }, ref) |
| 121 | test.RunGitCommand(t, true, "checkout", "master") |
| 122 | ref, err = CurrentRef() |
| 123 | assert.Nil(t, err) |
| 124 | assert.Equal(t, &Ref{ |
| 125 | Name: "master", |
| 126 | Type: RefTypeLocalBranch, |
| 127 | Sha: outputs[2].Sha, |
| 128 | }, ref) |
| 129 | // Check remote |
| 130 | repo.AddRemote("origin") |
| 131 | test.RunGitCommand(t, true, "push", "-u", "origin", "master:someremotebranch") |
nothing calls this directly
no test coverage detected