fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 1.5 kB View raw
1// Copyright 2019 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package gitindex 16 17import ( 18 "os/exec" 19 "testing" 20 21 git "github.com/go-git/go-git/v5" 22) 23 24func TestSetRemote(t *testing.T) { 25 t.Parallel() 26 27 dir := t.TempDir() 28 29 script := `mkdir orig 30cd orig 31git init -b master 32cd .. 33git clone orig/.git clone.git 34` 35 36 cmd := exec.Command("/bin/sh", "-euxc", script) 37 cmd.Dir = dir 38 39 if out, err := cmd.CombinedOutput(); err != nil { 40 t.Fatalf("execution error: %v, output %s", err, out) 41 } 42 43 r := dir + "/clone.git" 44 if err := setFetch(r, "origin", "+refs/heads/*:refs/heads/*"); err != nil { 45 t.Fatalf("addFetch: %v", err) 46 } 47 48 repo, err := git.PlainOpen(r) 49 if err != nil { 50 t.Fatal("PlainOpen", err) 51 } 52 53 rm, err := repo.Remote("origin") 54 if err != nil { 55 t.Fatal("Remote", err) 56 } 57 if got, want := rm.Config().Fetch[0].String(), "+refs/heads/*:refs/heads/*"; got != want { 58 t.Fatalf("got %q want %q", got, want) 59 } 60}