merge master

This commit is contained in:
Rick Olson 2015-04-27 15:18:12 -06:00
commit ae3f87342a
8 changed files with 20 additions and 1 deletions

@ -18,6 +18,7 @@ and clean filters (`git lfs get path/to/file`).
* Automatic GC for the `.git/lfs/objects` directory. * Automatic GC for the `.git/lfs/objects` directory.
* Client side metrics reporting, so the Git LFS server can optionally track * Client side metrics reporting, so the Git LFS server can optionally track
how clients are performing. how clients are performing.
* Ability to remove objects from the command line through the API.
## Possible Features ## Possible Features

@ -16,6 +16,7 @@ var (
) )
func cleanCommand(cmd *cobra.Command, args []string) { func cleanCommand(cmd *cobra.Command, args []string) {
requireStdin("This command should be run by the Git 'clean' filter")
lfs.InstallHooks(false) lfs.InstallHooks(false)
var filename string var filename string

@ -115,6 +115,8 @@ func pointerReader() (io.ReadCloser, error) {
return os.Open(pointerCompare) return os.Open(pointerCompare)
} }
requireStdin("The --stdin flag expects a pointer file from STDIN.")
return os.Stdin, nil return os.Stdin, nil
} }

@ -43,6 +43,8 @@ func pushCommand(cmd *cobra.Command, args []string) {
lfs.Config.CurrentRemote = args[0] lfs.Config.CurrentRemote = args[0]
if useStdin { if useStdin {
requireStdin("Run this command from the Git pre-push hook, or leave the --stdin flag off.")
// called from a pre-push hook! Update the existing pre-push hook if it's // called from a pre-push hook! Update the existing pre-push hook if it's
// one that git-lfs set. // one that git-lfs set.
lfs.InstallHooks(false) lfs.InstallHooks(false)

@ -20,6 +20,7 @@ var (
) )
func smudgeCommand(cmd *cobra.Command, args []string) { func smudgeCommand(cmd *cobra.Command, args []string) {
requireStdin("This command should be run by the Git 'smudge' filter")
lfs.InstallHooks(false) lfs.InstallHooks(false)
b := &bytes.Buffer{} b := &bytes.Buffer{}

@ -92,6 +92,14 @@ func PipeCommand(name string, args ...string) error {
return cmd.Run() return cmd.Run()
} }
func requireStdin(msg string) {
stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) != 0 {
Error("Cannot read from STDIN. %s", msg)
os.Exit(1)
}
}
func handlePanic(err error) string { func handlePanic(err error) string {
if err == nil { if err == nil {
return "" return ""

@ -79,7 +79,7 @@ func TestPointerWithInvalidCompareStdin(t *testing.T) {
defer repo.Test() defer repo.Test()
cmd := repo.Command("pointer", "--stdin") cmd := repo.Command("pointer", "--stdin")
cmd.Output = "Pointer from STDIN\n\nEOF" cmd.Output = "Cannot read from STDIN. The --stdin flag expects a pointer file from STDIN."
cmd.Unsuccessful = true cmd.Unsuccessful = true
} }

@ -72,6 +72,8 @@ The following status codes can optionally be returned from the API, depending on
the server implementation. the server implementation.
* 406 - The Accept header needs to be `application/vnd.git-lfs+json`. * 406 - The Accept header needs to be `application/vnd.git-lfs+json`.
* 410 - The requested object used to exist, but was deleted. The message should
state why (user initiated, legal issues, etc).
* 429 - The user has hit a rate limit with the server. Though the API does not * 429 - The user has hit a rate limit with the server. Though the API does not
specify any rate limits, implementors are encouraged to set some for specify any rate limits, implementors are encouraged to set some for
availability reasons. availability reasons.
@ -204,6 +206,8 @@ Here's a sample response for a request with an authorization error:
* 200 - The object exists and the user has access to download it. * 200 - The object exists and the user has access to download it.
* 401 - The authentication credentials are incorrect. * 401 - The authentication credentials are incorrect.
* 404 - The user does not have access to the object, or it does not exist. * 404 - The user does not have access to the object, or it does not exist.
* 410 - The object used to exist, but was deleted. The message should state why
(user initiated, legal issues, etc).
## POST /objects ## POST /objects