Skip to content

Commit 0335451

Browse files
committed
Following changes:
* Refactored code * Replaced Travis with Github Actions * Increased file sample size and improved file path logic * Improved doc * Go version upgrade and library upgrades
1 parent ae27647 commit 0335451

File tree

17 files changed

+339
-184
lines changed

17 files changed

+339
-184
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Golang
1313
uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.16
15+
go-version: 1.17
1616
- name: Build code
1717
run: go build
1818
- name: Test code

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
FROM golang:1.16.3-alpine3.13 as builder
1+
FROM golang:1.17-alpine3.14 as builder
2+
3+
RUN apk --no-cache add build-base
24

35
WORKDIR /opt/rsync-sidekick
46

5-
ADD . ./
7+
COPY ./go.mod ./go.sum ./
8+
9+
RUN go mod download -x
10+
11+
COPY . .
612

713
RUN go build
814

9-
FROM alpine:3.13
15+
RUN go test ./...
16+
17+
FROM alpine:3.14
1018

1119
RUN apk --no-cache add bash rsync
1220

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ This propagates following changes from _source directory_ to _destination direct
2121
Note:
2222

2323
* This tool **does not delete** any files or folders (under any circumstances) -- that's why safe-to-use 😌
24-
* Your files are just _moved around_
25-
* Now, if you're uncomfortable with this tool even moving your files around, there is a `-shellscript` option, that just generates a script for you to read and run (think of it like a `--dry-run` option)
24+
* Your files are just _moved around_
25+
* Now, if you're uncomfortable with this tool even moving your files around, there is a `-shellscript` option, that
26+
just generates a script for you to read and run (think of it like a `--dry-run` option)
2627
* This tool **does not** actually **transfer** files -- that's for `rsync` to do 🙂
27-
* Since you'd run `rsync` after this tool is run, any changes that this tool couldn't propagate would just be propagated by `rsync`
28-
* So the most that you might lose is some time with `rsync` doing more work than it could have -- Which is likely still much less than not using this tool at all 😄
28+
* Since you'd run `rsync` after this tool is run, any changes that this tool couldn't propagate would just be propagated
29+
by `rsync`
30+
* So the most that you might lose is some time with `rsync` doing more work than it could have -- Which is likely
31+
still much less than not using this tool at all 😄
2932

3033
## How to install?
3134

32-
1. Install Go **1.16**
35+
1. Install Go version at least **1.17**
3336
* On Ubuntu: `snap install go`
3437
* On Mac: `brew install go`
3538
* For anything else: [Go downloads page](https://golang.org/dl/)
@@ -58,7 +61,9 @@ rsync -av /Users/manu/Photos/ /Volumes/Portable/Photos/
5861
```
5962

6063
## Command line options
64+
6165
Running `rsync-sidekick -help` displays following information:
66+
6267
```
6368
usage:
6469
rsync-sidekick <flags> [source-dir] [destination-dir]
@@ -95,5 +100,6 @@ and sometimes are dangerous! `rsync-sidekick` is reliable alternative to all the
95100

96101
### How will I benefit from using this tool?
97102

98-
Using `rsync-sidekick` before `rsrync` makes your backup process significantly faster than using only `rsync`. Sometimes
99-
this performance benefit can even be 100x😲, if the only changes at your _source directory_ are the 3 types mentioned earlier in this article.
103+
Using `rsync-sidekick` before `rsrync` makes your backup process significantly faster than using only `rsync`. Sometimes
104+
this performance benefit can even be 100x😲, if the only changes at your _source directory_ are the 3 types mentioned
105+
earlier in this article.

doc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
Propagates file renames, movements and timestamp changes before rsync runs
3+
4+
Visit: https://github.com/m-manu/rsync-sidekick/
5+
*/
6+
package main

entity/string_set.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package entity
2+
3+
// StringSet is a set of string elements
4+
type StringSet map[string]struct{}
5+
6+
// StringSetOf creates a set with given elements
7+
func StringSetOf(s ...string) StringSet {
8+
set := make(StringSet, len(s))
9+
for i := 0; i < len(s); i++ {
10+
set[s[i]] = struct{}{}
11+
}
12+
return set
13+
}
14+
15+
// NewStringSet creates a set of given size
16+
func NewStringSet(size int) StringSet {
17+
return make(StringSet, size)
18+
}
19+
20+
// Add adds element to set
21+
func (set StringSet) Add(e string) {
22+
set[e] = struct{}{}
23+
}

filesutil/utils.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

go.mod

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
module github.com/m-manu/rsync-sidekick
22

3-
go 1.16
3+
go 1.17
44

55
require (
66
github.com/stretchr/testify v1.7.0
7-
golang.org/x/text v0.3.6
7+
golang.org/x/text v0.3.7
8+
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.0 // indirect
12+
github.com/pmezard/go-difflib v1.0.0 // indirect
13+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
814
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
55
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
66
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
77
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
8-
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
9-
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
8+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
9+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
1010
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
1111
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1212
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)