Skip to content

Commit efcfe38

Browse files
author
Laurent Cozic
committed
go fmt
1 parent c281cdb commit efcfe38

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

history.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
)
77

88
type HistoryItem struct {
9-
Source string
10-
Dest string
11-
Timestamp int64
12-
Id string
9+
Source string
10+
Dest string
11+
Timestamp int64
12+
Id string
1313
IntermediatePath string
1414
}
1515

main.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ type CommandLineOptions struct {
4141
}
4242

4343
type FileAction struct {
44-
oldPath string
45-
newPath string
44+
oldPath string
45+
newPath string
4646
intermediatePath string
47-
kind int
47+
kind int
4848
}
4949

5050
type DeleteOperationsFirst []*FileAction
51+
5152
func (a DeleteOperationsFirst) Len() int { return len(a) }
5253
func (a DeleteOperationsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
5354
func (a DeleteOperationsFirst) Less(i, j int) bool { return a[i].kind == KIND_DELETE }
@@ -397,7 +398,7 @@ func fileActions(originalFilePaths []string, changedContent string) ([]*FileActi
397398
break
398399
}
399400
}
400-
if (!ok) {
401+
if !ok {
401402
return []*FileAction{}, errors.New(fmt.Sprintf("\"%s\" cannot be renamed to \"%s\": destination already exists", action.FullOldPath(), action.FullNewPath()))
402403
}
403404
}

main_test.go

+13-14
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ ijkl
190190
},
191191
},
192192
})
193-
193+
194194
testCases = append(testCases, TestCase{
195195
paths: []string{
196196
" abcd",
@@ -207,7 +207,7 @@ ijkl
207207
// across platforms.
208208
newline_ = "\n"
209209

210-
for _, testCase := range testCases {
210+
for _, testCase := range testCases {
211211
// Note: Run tests with -v in case of error
212212

213213
r, _ := fileActions(testCase.paths, testCase.content)
@@ -312,7 +312,7 @@ func Test_processFileActions(t *testing.T) {
312312
func Test_processFileActions_noDestinationOverwrite(t *testing.T) {
313313
setup(t)
314314
defer teardown(t)
315-
315+
316316
// Case where a sequence of files such as 0.jpg, 1.jpg is being
317317
// renamed to 1.jpg, 2.jpg
318318

@@ -322,7 +322,7 @@ func Test_processFileActions_noDestinationOverwrite(t *testing.T) {
322322

323323
filePutContent(p0, "0")
324324
filePutContent(p1, "1")
325-
325+
326326
fileActions := []*FileAction{}
327327

328328
fileAction := NewFileAction()
@@ -336,7 +336,7 @@ func Test_processFileActions_noDestinationOverwrite(t *testing.T) {
336336
fileActions = append(fileActions, fileAction)
337337

338338
err := processFileActions(fileActions, false)
339-
339+
340340
if err != nil {
341341
t.Errorf("Expected no error, but got an error.")
342342
}
@@ -365,10 +365,10 @@ func Test_processFileActions_noDestinationOverwrite(t *testing.T) {
365365
func Test_processFileActions_noDestinationOverwrite2(t *testing.T) {
366366
setup(t)
367367
defer teardown(t)
368-
368+
369369
// Case where a file is renamed to the name of
370370
// another existing file.
371-
371+
372372
touch(filepath.Join(tempFolder(), "0"))
373373
touch(filepath.Join(tempFolder(), "1"))
374374

@@ -380,7 +380,7 @@ func Test_processFileActions_noDestinationOverwrite2(t *testing.T) {
380380
1
381381
`
382382
_, err := fileActions(originalFilePaths, changes)
383-
383+
384384
if err == nil {
385385
t.Error("Expected an error, but got nil.")
386386
}
@@ -407,7 +407,7 @@ func Test_processFileActions_swapFilenames(t *testing.T) {
407407
`
408408
actions, _ := fileActions(originalFilePaths, changes)
409409
err := processFileActions(actions, false)
410-
410+
411411
if err != nil {
412412
t.Error("Expected no error, but got one.")
413413
}
@@ -421,11 +421,10 @@ func Test_processFileActions_swapFilenames(t *testing.T) {
421421
}
422422
}
423423

424-
425424
func Test_processFileActions_renameToSameName(t *testing.T) {
426425
setup(t)
427426
defer teardown(t)
428-
427+
429428
touch(filepath.Join(tempFolder(), "0"))
430429
touch(filepath.Join(tempFolder(), "1"))
431430

@@ -439,7 +438,7 @@ func Test_processFileActions_renameToSameName(t *testing.T) {
439438
9
440439
`
441440
_, err := fileActions(originalFilePaths, changes)
442-
441+
443442
if err == nil {
444443
t.Error("Expected an error, but got nil.")
445444
}
@@ -448,7 +447,7 @@ func Test_processFileActions_renameToSameName(t *testing.T) {
448447
func Test_processFileActions_dontDeleteAfterRename(t *testing.T) {
449448
setup(t)
450449
defer teardown(t)
451-
450+
452451
p0 := filepath.Join(tempFolder(), "0")
453452
p1 := filepath.Join(tempFolder(), "1")
454453
filePutContent(p0, "0")
@@ -465,7 +464,7 @@ func Test_processFileActions_dontDeleteAfterRename(t *testing.T) {
465464
`
466465
actions, _ := fileActions(originalFilePaths, changes)
467466
err := processFileActions(actions, false)
468-
467+
469468
if err != nil {
470469
t.Error("Expected no error, but got one.")
471470
}

undo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4-
"os"
54
"github.com/nu7hatch/gouuid"
5+
"os"
66
)
77

88
func handleUndoCommand(opts *CommandLineOptions, args []string) error {
@@ -27,7 +27,7 @@ func handleUndoCommand(opts *CommandLineOptions, args []string) error {
2727
logInfo("\"%s\" => \"%s\"", item.Dest, item.Source)
2828
} else {
2929
logDebug("\"%s\" => \"%s\"", item.Dest, item.Source)
30-
30+
3131
if _, err := os.Stat(item.Source); os.IsNotExist(err) {
3232
err = os.Rename(item.Dest, item.Source)
3333
if err != nil {

undo_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func Test_handleUndoCommand_withIntermediateRename(t *testing.T) {
141141

142142
filePutContent(p0, "0")
143143
filePutContent(p1, "1")
144-
144+
145145
fileActions := []*FileAction{}
146146

147147
fileAction := NewFileAction()

0 commit comments

Comments
 (0)