Commit 94e5c8a8 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Merge branch 'revert-ac135837' into 'master'

Revert "Merge branch '4097-branch-is-no-longer-checked-out-when-using-refspec' into 'master'"

See merge request gitlab-org/gitlab-runner!1283
parents ac135837 ad80cf6c
......@@ -875,42 +875,6 @@ func TestBuildChangesBranchesWhenFetchingRepo(t *testing.T) {
})
}
func TestBranchAvailableLocally(t *testing.T) {
shellstest.OnEachShell(t, func(t *testing.T, shell string) {
successfulBuild, err := common.GetRemoteSuccessfulBuild()
assert.NoError(t, err)
build, cleanup := newBuild(t, successfulBuild, shell)
defer cleanup()
build.Variables = append(build.Variables, common.JobVariable{Key: "GIT_STRATEGY", Value: "fetch"})
out, err := runBuildReturningOutput(t, build)
assert.NoError(t, err)
assert.Contains(t, out, "Created fresh repository")
assert.Regexp(t, "Checking out [a-f0-9]+ as", out)
f, err := ioutil.ReadFile(filepath.Join(build.FullProjectDir(), ".git/refs/heads/master"))
require.NoError(t, err)
assert.Equal(t, build.GitInfo.Sha, strings.TrimSuffix(string(f), "\n"))
out, err = runBuildReturningOutput(t, build)
assert.NoError(t, err)
assert.Contains(t, out, "Fetching changes")
assert.Regexp(t, "Checking out [a-f0-9]+ as", out)
f, err = ioutil.ReadFile(filepath.Join(build.FullProjectDir(), ".git/refs/heads/master"))
require.NoError(t, err)
assert.Equal(t, build.GitInfo.Sha, strings.TrimSuffix(string(f), "\n"))
build.GitInfo = common.GetLFSGitInfo(build.GitInfo.RepoURL)
out, err = runBuildReturningOutput(t, build)
assert.NoError(t, err)
assert.Contains(t, out, "Fetching changes")
assert.Regexp(t, "Checking out [a-f0-9]+ as", out)
f, err = ioutil.ReadFile(filepath.Join(build.FullProjectDir(), ".git/refs/heads/add-lfs-object"))
require.NoError(t, err)
assert.Equal(t, build.GitInfo.Sha, strings.TrimSuffix(string(f), "\n"))
})
}
func TestInteractiveTerminal(t *testing.T) {
cases := []struct {
app string
......
......@@ -182,13 +182,6 @@ func (b *AbstractShell) writeRefspecFetchCmd(w ShellWriter, build *common.Build,
func (b *AbstractShell) writeCheckoutCmd(w ShellWriter, build *common.Build) {
w.Notice("Checking out %s as %s...", build.GitInfo.Sha[0:8], build.GitInfo.Ref)
w.Command("git", "checkout", "-f", "-q", build.GitInfo.Sha)
// Use `git fetch $REMOTE $BRANCH:$BRANCH` to create the branch locally. We
// need to have it available locally so users can push branches to other
// remotes.
if build.GitInfo.RefType == common.RefTypeBranch {
w.Command("git", "fetch", "origin", fmt.Sprintf("%s:%s", build.GitInfo.Ref, build.GitInfo.Ref))
}
}
func (b *AbstractShell) writeSubmoduleUpdateCmd(w ShellWriter, build *common.Build, recursive bool) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment