Fix pre-push hook when multiple branches are pushed in one git push

This commit is contained in:
Steve Streeting 2015-09-04 14:59:56 +01:00
parent e59352900e
commit d7589752a9

@ -1,7 +1,7 @@
package commands
import (
"io/ioutil"
"bufio"
"os"
"strings"
@ -43,7 +43,6 @@ var (
// In the case of deleting a branch, no attempts to push Git LFS objects will be
// made.
func prePushCommand(cmd *cobra.Command, args []string) {
var left, right string
if len(args) == 0 {
Print("This should be run through Git's pre-push hook. Run `git lfs update` to install it.")
@ -52,16 +51,16 @@ func prePushCommand(cmd *cobra.Command, args []string) {
lfs.Config.CurrentRemote = args[0]
refsData, err := ioutil.ReadAll(os.Stdin)
if err != nil {
Panic(err, "Error reading refs on stdin")
// We can be passed multiple lines of refs
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if len(line) == 0 {
continue
}
if len(refsData) == 0 {
return
}
left, right = decodeRefs(string(refsData))
left, right := decodeRefs(line)
if left == prePushDeleteBranch {
return
}
@ -128,6 +127,7 @@ func prePushCommand(cmd *cobra.Command, args []string) {
}
}
}
}
func prePushCheckForMissingObjects(pointers []*lfs.WrappedPointer) (objectsOnServer map[string]struct{}) {
var missingLocalObjects []*lfs.WrappedPointer