Skip to content

Commit

Permalink
Merge branches 'yaml' and 'basedir'
Browse files Browse the repository at this point in the history
  • Loading branch information
anishathalye committed May 30, 2018
3 parents 2f4cc0d + 7a19cd2 + c3f2714 commit b5ab016
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "lib/pyyaml"]
path = lib/pyyaml
url = https://github.com/anishathalye/pyyaml
url = https://github.com/yaml/pyyaml
ignore = dirty
9 changes: 5 additions & 4 deletions dotbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def add_options(parser):
help='suppress most output')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='enable verbose output')
parser.add_argument('-d', '--base-directory', nargs=1,
parser.add_argument('-d', '--base-directory',
dest='base_directory', help='execute commands from within BASEDIR',
metavar='BASEDIR', required=True)
parser.add_argument('-c', '--config-file', nargs=1, dest='config_file',
parser.add_argument('-c', '--config-file', dest='config_file',
help='run commands given in CONFIGFILE', metavar='CONFIGFILE',
required=True)
parser.add_argument('-p', '--plugin', action='append', dest='plugins', default=[],
Expand Down Expand Up @@ -55,10 +55,11 @@ def main():
for plugin_path in plugin_paths:
abspath = os.path.abspath(plugin_path)
module.load(abspath)
tasks = read_config(options.config_file[0])
tasks = read_config(options.config_file)
if not isinstance(tasks, list):
raise ReadingError('Configuration file must be a list of tasks')
dispatcher = Dispatcher(options.base_directory[0])
os.chdir(options.base_directory)
dispatcher = Dispatcher(options.base_directory)
success = dispatcher.dispatch(tasks)
if success:
log.info('\n==> All tasks executed successfully')
Expand Down
3 changes: 1 addition & 2 deletions test/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ Vagrant.configure(2) do |config|
config.vm.box = 'debian/stretch64'

# sync by copying for isolation
config.vm.synced_folder "..", "/dotbot", type: "rsync",
rsync__exclude: ".git/"
config.vm.synced_folder "..", "/dotbot", type: "rsync"

# disable default synced folder
config.vm.synced_folder ".", "/vagrant", disabled: true
Expand Down
16 changes: 5 additions & 11 deletions test/test-lib.bash
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
DEBUG=${DEBUG:-false}
USE_VAGRANT=${USE_VAGRANT:-true}
if ${USE_VAGRANT}; then
DOTBOT_EXEC=${DOTBOT_EXEC:-"python /dotbot/bin/dotbot"}
else
DOTBOT_EXEC=${DOTBOT_EXEC:-"/dotbot/bin/dotbot"}
fi
DOTBOT_EXEC=${DOTBOT_EXEC:-"python /dotbot/bin/dotbot"}
DOTFILES="/home/$(whoami)/dotfiles"
INSTALL_CONF='install.conf.yaml'
INSTALL_CONF_JSON='install.conf.json'
Expand Down Expand Up @@ -51,17 +47,15 @@ initialize() {

run_dotbot() {
(
cd "${DOTFILES}"
cat > "${INSTALL_CONF}"
${DOTBOT_EXEC} -d . -c "${INSTALL_CONF}" "${@}"
cat > "${DOTFILES}/${INSTALL_CONF}"
${DOTBOT_EXEC} -d "${DOTFILES}" -c "${DOTFILES}/${INSTALL_CONF}" "${@}"
)
}

run_dotbot_json() {
(
cd "${DOTFILES}"
cat > "${INSTALL_CONF_JSON}"
${DOTBOT_EXEC} -d . -c "${INSTALL_CONF_JSON}" "${@}"
cat > "${DOTFILES}/${INSTALL_CONF_JSON}"
${DOTBOT_EXEC} -d "${DOTFILES}" -c "${DOTFILES}/${INSTALL_CONF_JSON}" "${@}"
)
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_travis
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# set -x
# set -v

BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

# Prevent execution outside of Travis CI builds
if [[ "${TRAVIS}" != true || "${CI}" != true ]]; then
Expand Down
2 changes: 1 addition & 1 deletion test/tests/plugin-dir.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ EOF
'

test_expect_success 'run' '
run_dotbot --plugin-dir plugins <<EOF
run_dotbot --plugin-dir ${DOTFILES}/plugins <<EOF
- test: ~
EOF
'
Expand Down
2 changes: 1 addition & 1 deletion test/tests/plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ EOF
'

test_expect_success 'run' '
run_dotbot --plugin test.py <<EOF
run_dotbot --plugin ${DOTFILES}/test.py <<EOF
- test: ~
EOF
'
Expand Down
29 changes: 29 additions & 0 deletions test/tests/shim.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
test_description='install shim works'
. '../test-lib.bash'

test_expect_success 'setup' '
cd ${DOTFILES}
git init
if ${USE_VAGRANT}; then
git submodule add /dotbot dotbot
else
git submodule add ${BASEDIR} dotbot
fi
cp ./dotbot/tools/git-submodule/install .
echo "pear" > ${DOTFILES}/foo
'

test_expect_success 'run' '
cat > ${DOTFILES}/install.conf.yaml <<EOF
- link:
~/.foo: foo
EOF
if ! ${USE_VAGRANT}; then
sed -i "" "1 s/sh$/python/" ${DOTFILES}/dotbot/bin/dotbot
fi
${DOTFILES}/install
'

test_expect_success 'test' '
grep "pear" ~/.foo
'
1 change: 1 addition & 0 deletions tools/git-submodule/install
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

cd "${BASEDIR}"
git -C "${DOTBOT_DIR}" submodule sync --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"

"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}"

0 comments on commit b5ab016

Please sign in to comment.