MCPcopy
hub / github.com/git-lfs/git-lfs / ensureWorkingCopyClean

Function ensureWorkingCopyClean

commands/command_migrate.go:337–387  ·  view source on GitHub ↗
(in io.Reader, out io.Writer)

Source from the content-addressed store, hash-verified

335}
336
337func ensureWorkingCopyClean(in io.Reader, out io.Writer) {
338 dirty, err := git.IsWorkingCopyDirty()
339 if err != nil {
340 ExitWithError(errors.Wrap(err,
341 tr.Tr.Get("Could not determine if working copy is dirty")))
342 }
343
344 if !dirty {
345 return
346 }
347
348 var proceed bool
349 if migrateYes {
350 proceed = true
351 } else {
352 answer := bufio.NewReader(in)
353 L:
354 for {
355 fmt.Fprint(out, tr.Tr.Get("override changes in your working copy? All uncommitted changes will be lost! [y/N] "))
356 s, err := answer.ReadString('\n')
357 if err != nil {
358 if err == io.EOF {
359 break L
360 }
361 ExitWithError(errors.Wrap(err,
362 tr.Tr.Get("Could not read answer")))
363 }
364
365 switch strings.TrimSpace(s) {
366 // TRANSLATORS: these are negative (no) responses.
367 case tr.Tr.Get("n"), tr.Tr.Get("N"), "":
368 proceed = false
369 break L
370 // TRANSLATORS: these are positive (yes) responses.
371 case tr.Tr.Get("y"), tr.Tr.Get("Y"):
372 proceed = true
373 break L
374 }
375
376 if !strings.HasSuffix(s, "\n") {
377 fmt.Fprintf(out, "\n")
378 }
379 }
380 }
381
382 if proceed {
383 fmt.Fprintln(out, tr.Tr.Get("changes in your working copy will be overridden ..."))
384 } else {
385 Exit(tr.Tr.Get("working copy must not be dirty"))
386 }
387}
388
389func init() {
390 info := NewCommand("info", migrateInfoCommand)

Callers 2

migrateImportCommandFunction · 0.85
migrateExportCommandFunction · 0.85

Calls 5

IsWorkingCopyDirtyFunction · 0.92
WrapFunction · 0.92
ExitWithErrorFunction · 0.85
ExitFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected