Skip to content

Commit

Permalink
Merge pull request #70 from cytopia/release-1.3.1
Browse files Browse the repository at this point in the history
Release v1.3.1
  • Loading branch information
cytopia authored Dec 2, 2021
2 parents 45a03e6 + 9f04dbe commit c4629a3
Show file tree
Hide file tree
Showing 21 changed files with 962 additions and 181 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
- test-local-no_perms
- test-local-no_times
- test-local-copy_links
- test-local-crazy-filename-chars
- test-local-crazy-pathname-chars

name: "[Linux ${{ matrix.target }}]"
steps:
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/macos-10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---

# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: MacOS-10


# -------------------------------------------------------------------------------------------------
# When to run
# -------------------------------------------------------------------------------------------------
on:
# Runs on Pull Requests
pull_request:

# Runs on master Branch and Tags
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+*'


# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
macos-10:

runs-on: macos-10.15

strategy:
fail-fast: false
matrix:
target:
- test-local-default-abs-noslash-noslash
- test-local-default-abs-noslash-slash
- test-local-default-abs-slash-noslash
- test-local-default-abs-slash-slash
- test-local-default-rel-noslash-noslash
- test-local-default-rel-noslash-slash
- test-local-default-rel-slash-noslash
- test-local-default-rel-slash-slash
- test-local-no_perms
- test-local-no_times
- test-local-copy_links
- test-local-crazy-filename-chars
- test-local-crazy-pathname-chars

name: "[MacOS ${{ matrix.target }}]"
steps:

# ------------------------------------------------------------
# Checkout repository
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v1

- name: Show environment
shell: bash
run: |
env
- name: Show user
shell: bash
run: |
id
- name: Show bash versions
shell: bash
run: |
bash --version
- name: Show rsync versions
shell: bash
run: |
rsync --version
# ------------------------------------------------------------
# Install
# ------------------------------------------------------------
- name: Install
shell: bash
run: |
sudo make install
/usr/local/bin/timemachine --version
# ------------------------------------------------------------
# Test
# ------------------------------------------------------------
- name: Test
shell: bash
run: |
make ${TARGET}
env:
TARGET: ${{ matrix.target }}

# ------------------------------------------------------------
# Uninstall
# ------------------------------------------------------------
- name: Uninstall
shell: bash
run: |
sudo make uninstall
if test -f /usr/local/bin/timemachine >/dev/null 2>&1; then false; fi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: MacOS
name: MacOS-11


# -------------------------------------------------------------------------------------------------
Expand All @@ -25,9 +25,9 @@ on:
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
macos:
macos-11:

runs-on: macos-latest
runs-on: macos-11

strategy:
fail-fast: false
Expand All @@ -44,6 +44,8 @@ jobs:
- test-local-no_perms
- test-local-no_times
- test-local-copy_links
- test-local-crazy-filename-chars
- test-local-crazy-pathname-chars

name: "[MacOS ${{ matrix.target }}]"
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ssh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- test-remote-ssh_config-default
- test-remote-ssh_config-port_1111
- test-remote-ssh_config-port_overwrite
- test-remote-ssh_crazy-source-pathname-chars

name: "[SSH ${{ matrix.target }}]"
steps:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Changelog


## Release v1.3.1

#### Changed
- Switch to semver for versioning
- Wrap rsync into eval to escape paths

#### Added
- CI: check for special chars in file names

#### Fixed
- Fixed #69 special chars in source directory
- Fixed #67 argument parsing


## Release v1.2

#### Fixed
Expand Down
Empty file modified LICENSE.md
100755 → 100644
Empty file.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ test: test-local-default-rel-slash-slash
test: test-local-no_perms
test: test-local-no_times
test: test-local-copy_links
test: test-local-crazy-filename-chars
test: test-local-crazy-pathname-chars
test: test-remote-default-abs
test: test-remote-default-rel
test: test-remote-ssh_1111_port-nouser
Expand All @@ -102,7 +104,7 @@ test: test-remote-ssh_def_port-user
test: test-remote-ssh_config-default
test: test-remote-ssh_config-port_1111
test: test-remote-ssh_config-port_overwrite

test: test-remote-ssh_crazy-source-pathname-chars

test-local-default-abs-noslash-noslash:
./tests/01-run-local-default-abs-noslash-noslash.sh
Expand Down Expand Up @@ -137,6 +139,11 @@ test-local-no_times:
test-local-copy_links:
./tests/05-run-local-copy_links.sh

test-local-crazy-filename-chars:
./tests/06-run-local-crazy-filename-chars.sh

test-local-crazy-pathname-chars:
./tests/06-run-local-crazy-pathname-chars.sh

test-remote-default-abs:
./tests/10-run-remote-default-abs.sh
Expand Down Expand Up @@ -171,6 +178,9 @@ test-remote-ssh_config-port_1111:
test-remote-ssh_config-port_overwrite:
./tests/12-run-remote-ssh_config-port_overwrite.sh

test-remote-ssh_crazy-source-pathname-chars:
./tests/13-run-remote-crazy-source-pathname-chars.sh


# -------------------------------------------------------------------------------------------------
# Helper targets
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

[![Linting](https://github.com/cytopia/linux-timemachine/workflows/Linting/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=Linting)
[![Linux](https://github.com/cytopia/linux-timemachine/workflows/Linux/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=Linux)
[![MacOS](https://github.com/cytopia/linux-timemachine/workflows/MacOS/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=MacOS)
[![MacOS 10](https://github.com/cytopia/linux-timemachine/workflows/MacOS-10/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=MacOS-10)
[![MacOS 11](https://github.com/cytopia/linux-timemachine/workflows/MacOS-11/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=MacOS-11)
[![SSH](https://github.com/cytopia/linux-timemachine/workflows/SSH/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=SSH)
[![Tag](https://img.shields.io/github/tag/cytopia/linux-timemachine.svg)](https://github.com/cytopia/linux-timemachine/releases)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -198,7 +199,8 @@ Retention is a delicate topic as you want to be sure that data is removed as int

[![Linting](https://github.com/cytopia/linux-timemachine/workflows/Linting/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=Linting)
[![Linux](https://github.com/cytopia/linux-timemachine/workflows/Linux/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=Linux)
[![MacOS](https://github.com/cytopia/linux-timemachine/workflows/MacOS/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=MacOS)
[![MacOS 10](https://github.com/cytopia/linux-timemachine/workflows/MacOS-10/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=MacOS-10)
[![MacOS 11](https://github.com/cytopia/linux-timemachine/workflows/MacOS-11/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=MacOS-11)
[![SSH](https://github.com/cytopia/linux-timemachine/workflows/SSH/badge.svg)](https://github.com/cytopia/linux-timemachine/actions?workflow=SSH)

The script is written and maintained with maximum care.
Expand Down
44 changes: 32 additions & 12 deletions tests/.lib/create-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,35 @@ set -o pipefail
create_file() {
local src_dir="${1}"
local file_name="${2}"
local sub_dir=
local file_path=
local file_size="${3}"
local file_perms="${4}"

local file_path="${src_dir}/${file_name}"
file_name="$( printf "%q" "${file_name}" )"
sub_dir="$( printf "%q" "$( eval "dirname ${file_name}" )" )"
file_path="${src_dir}/${file_name}"

# Create directory if it doesn't exist
if [ ! -d "$( dirname "${file_path}" )" ]; then
run "mkdir -p $( dirname "${file_path}" )"
if ! eval "test -d ${src_dir}"; then
printf "No such directpry: %s\\n" "${src_dir}"
return 1
fi
# Create sub-directory if it doesn't exist
if [ "${sub_dir}" != "." ]; then
printf "# Create basedir: %s\\n" "${sub_dir}"
run "mkdir -p ${src_dir}/${sub_dir}"
fi

if [ "$(uname)" = "Linux" ]; then
run "dd if=/dev/zero of=${file_path} bs=1M count=${file_size} 2>/dev/null"
else
run "dd if=/dev/zero of=${file_path} bs=1m count=${file_size} 2>/dev/null"
fi
run "chmod ${file_perms} '${file_path}'"
run "chmod ${file_perms} ${file_path}"

if ! eval "test -f ${file_path}"; then
echo "No file created: ${file_path}"
return 1
fi
}


Expand All @@ -40,13 +53,20 @@ create_file() {
create_link() {
local src_dir="${1}"
local link_name="${2}"
local sub_dir=
local link_from="${3}"
local link_path="${src_dir}/${link_name}"

# Create directory if it doesn't exist
if [ ! -d "$( dirname "${link_path}" )" ]; then
run "mkdir -p $( dirname "${link_path}" )"
fi
link_name="$( printf "%q" "${link_name}" )"
sub_dir="$( printf "%q" "$( eval "dirname ${link_name}" )" )"

run "cd '${src_dir}' && ln -s '${link_from}' '${link_name}'"
if ! eval "test -d ${src_dir}"; then
printf "No such directpry: %s\\n" "${src_dir}"
return 1
fi
# Create sub-directory if it doesn't exist
if [ "${sub_dir}" != "." ]; then
printf "# Create basedir: %s\\n" "${sub_dir}"
run "mkdir -p ${src_dir}/${sub_dir}"
fi
run "cd ${src_dir} && ln -s ${link_from} ${link_name}"
}
24 changes: 14 additions & 10 deletions tests/.lib/dir-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ set -o pipefail
# -------------------------------------------------------------------------------------------------

check_dir_size() {
local src="${1}"
local dst="${2}"
local src=
local dst=
src="$( printf "%q" "${1}" )"
dst="$( printf "%q" "${2}" )"

src_size="$( get_dir_size_with_hardlinks "${src}" )"
dst_size="$( get_dir_size_with_hardlinks "${dst}" )"
Expand All @@ -21,7 +23,7 @@ check_dir_size() {
return 0
fi
printf "[TEST] [FAIL] src-dir(%s) and dst-dir(%s) size don't match: (src: %s) (dst: %s)\\r\\n" "${src_size}" "${dst_size}" "${src}" "${dst}"
exit 1
return 1
}


Expand All @@ -36,9 +38,9 @@ check_dir_size() {
### @param abs_path directory
###
get_dir_size_with_hardlinks() {
local dir="${1}"
local dir=
local size=

dir="$( printf "%q" "${1}" )"

size="$( run "cd '${dir}' && du -d0 '.' | awk '{print \$1}'" "1" "stderr" )"
echo "${size}"
Expand All @@ -51,23 +53,25 @@ get_dir_size_with_hardlinks() {
### @param abs_path directory
###
get_dir_size_without_hardlinks() {
local dir="${1}"
local dir=
dir="$( printf "%q" "${1}" )"
local suffix="${2:-}"
local actual_path=
local current_dir_name=
local parent_dir_path=
local size=


# Return the actual path (in case we're in a symlink)
actual_path="$( run "cd '${dir}' && pwd -P" "1" "stderr" )"
actual_path="$( printf "%q" "$( run "cd ${dir} && pwd -P" "1" "stderr" )" )"

# Get only the name of the current directory
current_dir_name="$( run "basename '${actual_path}'" "1" "stderr" )"
current_dir_name="$( printf "%q" "$( run "basename ${actual_path}" "1" "stderr" )" )"

# Get the parent directory path
parent_dir_path="$( run "dirname '${actual_path}'" "1" "stderr" )"
parent_dir_path="$( printf "%q" "$( run "dirname ${actual_path}" "1" "stderr" )" )"


size="$( run "cd '${parent_dir_path}' && du -d2 2>/dev/null | grep -E '${current_dir_name}${suffix}\$' | head -1 | awk '{print \$1}'" "1" "stderr" )"
size="$( run "cd ${parent_dir_path} && du -d2 2>/dev/null | grep -E '${current_dir_name}${suffix}\$' | head -1 | awk '{print \$1}'" "1" "stderr" )"
echo "${size}"
}
Loading

0 comments on commit c4629a3

Please sign in to comment.