mirror of
https://github.com/itchyny/mmv.git
synced 2025-12-26 22:24:58 +08:00
remove renames with same source and destination
This commit is contained in:
parent
0926ef4faa
commit
d838f2b136
2 changed files with 30 additions and 0 deletions
6
mmv.go
6
mmv.go
|
|
@ -61,6 +61,12 @@ func buildRenames(files map[string]string) ([]rename, error) {
|
|||
}
|
||||
revs[dst] = src
|
||||
}
|
||||
for src, dst := range files {
|
||||
if src == dst {
|
||||
delete(files, src)
|
||||
delete(revs, dst)
|
||||
}
|
||||
}
|
||||
var i int
|
||||
for _, dst := range files {
|
||||
if vs[dst] > 0 {
|
||||
|
|
|
|||
24
mmv_test.go
24
mmv_test.go
|
|
@ -198,6 +198,30 @@ func TestRename(t *testing.T) {
|
|||
},
|
||||
err: &sameDestinationError{"baz"},
|
||||
},
|
||||
{
|
||||
name: "same source and destination",
|
||||
files: map[string]string{
|
||||
"foo/": "foo",
|
||||
"bar/": "bar",
|
||||
},
|
||||
cnt: 0,
|
||||
contents: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
expected: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "same source and destination with error",
|
||||
files: map[string]string{
|
||||
"foo/": "foo/",
|
||||
"bar/": "foo",
|
||||
},
|
||||
err: &sameDestinationError{"foo"},
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue