From 896e0fb99d62be8f19dff79e41c9a2bd7ea723b1 Mon Sep 17 00:00:00 2001 From: Jesús García Crespo Date: Tue, 26 Feb 2013 11:44:25 -0800 Subject: Remove unneeded whitespaces and fix typo --- dotfiles/cli.py | 2 +- dotfiles/core.py | 2 +- test_dotfiles.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dotfiles/cli.py b/dotfiles/cli.py index 940495e..3726e0d 100644 --- a/dotfiles/cli.py +++ b/dotfiles/cli.py @@ -212,7 +212,7 @@ def main(): (cli_opts, args) = parse_args() - settings['homedir'] = realpath_expanduser(cli_opts.homedir or + settings['homedir'] = realpath_expanduser(cli_opts.homedir or defaults['homedir']) settings['config_file'] = realpath_expanduser(cli_opts.config_file or defaults['config_file']) diff --git a/dotfiles/core.py b/dotfiles/core.py index 1dfcea7..f2b492b 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -152,7 +152,7 @@ class Dotfiles(object): self._load_recursive(pkg_path) else: self.dotfiles.append(Dotfile(dotfile[len(self.prefix):], - os.path.join(src_dir, dotfile), dst_dir, + os.path.join(src_dir, dotfile), dst_dir, add_dot=not bool(sub_dir), dry_run=self.dry_run)) # Externals are top-level only diff --git a/test_dotfiles.py b/test_dotfiles.py index 88ffe67..cce8009 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -180,7 +180,7 @@ class DotfilesTestCase(unittest.TestCase): self.assertPathEqual( os.path.join(self.repository, original), os.path.join(self.homedir, symlink)) - + def test_packages(self): """ Test packages. @@ -197,7 +197,7 @@ class DotfilesTestCase(unittest.TestCase): os.makedirs(dirname) touch(path) - # Create Dotiles object + # Create Dotfiles object dotfiles = core.Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=['package'], -- cgit v1.2.3 From bffc06a95eb978ce96f1b25efc2c01b034c45244 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 4 Jun 2013 22:41:10 -0400 Subject: Mention using Dropbox to synchronize a dotfiles repository --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index dca0e9b..bda23e2 100644 --- a/README.rst +++ b/README.rst @@ -4,8 +4,8 @@ Dotfile management made easy ``dotfiles`` is a tool to make managing your dotfile symlinks in ``$HOME`` easy, allowing you to keep all your dotfiles in a single directory. -Hosting is up to you. Using whatever VCS you prefer, or even rsync, you can -easily distribute your dotfiles repository across multiple hosts. +Hosting is up to you. You can use a VCS like git, Dropbox, or even rsync to +distribute your dotfiles repository across multiple hosts. The repository can be specified at runtime, so you can manage multiple repositories without hassle. See the Configuration_ section below for further -- cgit v1.2.3 From ed3daa1f190e60a3b801990de68567df09d8bea1 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 18 Jun 2013 21:53:46 -0400 Subject: Add travis configuration file for continuous integration --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d144940 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + - "2.5" + - "2.6" + - "2.7" + - "3.2" + - "3.3" -- cgit v1.2.3 From a232385aadf5a4f7065c14e183ccbd667e131a0b Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 18 Jun 2013 22:18:26 -0400 Subject: Include pypi and travis-ci badges on README.rst --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index bda23e2..4f93ec0 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,12 @@ Dotfile management made easy ============================ +.. image:: https://pypip.in/v/dotfiles/badge.png + :target: https://pypi.python.org/pypi/dotfiles + +.. image:: https://secure.travis-ci.org/jbernard/dotfiles.png?branch=develop + :target: http://travis-ci.org/jbernard/dotfiles + ``dotfiles`` is a tool to make managing your dotfile symlinks in ``$HOME`` easy, allowing you to keep all your dotfiles in a single directory. -- cgit v1.2.3 From 52551696de34a28dd5de1799aaa2ec50c50aceb4 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 18 Jun 2013 22:31:30 -0400 Subject: Define travis install and test directives --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index d144940..8e6edd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,11 @@ python: - "2.7" - "3.2" - "3.3" + +# command to install dependencies +install: + - "pip install . --use-mirrors" + +# command to run tests +script: + - "python test_dotfiles.py" -- cgit v1.2.3 From 33f63740fdc9e738a9638d94f0f646c762472b89 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 27 Jun 2013 10:43:12 -0400 Subject: Add a unit test for non-existent package directories If a package is defined in .dotfilesrc and the package directory doesn't exist in the repository when you attempt to add it, an IOError exception is thrown. This test captures the failing scenario. In reference to #17. --- test_dotfiles.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test_dotfiles.py b/test_dotfiles.py index cce8009..ad4bba6 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -232,6 +232,27 @@ class DotfilesTestCase(unittest.TestCase): dotfiles.move(self.repository) check_all(files, symlinks) + def test_missing_package(self): + """ + Test a non-existent package. + """ + + package_file = '.package/bar' + + # Create Dotfiles object + dotfiles = core.Dotfiles( + homedir=self.homedir, repository=self.repository, + prefix='', ignore=[], externals={}, packages=['package'], + dry_run=False) + + path = os.path.join(self.homedir, package_file) + dirname = os.path.dirname(path) + if not os.path.exists(dirname): + os.makedirs(dirname) + touch(path) + + dotfiles.add([os.path.join(self.homedir, package_file)]) + def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) -- cgit v1.2.3 From 6676d85be6285826b9c1df73ce878ba9c667489d Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 27 Jun 2013 10:55:01 -0400 Subject: Create non-existent package directories Closes #17. --- dotfiles/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dotfiles/core.py b/dotfiles/core.py index f2b492b..e4c4ec6 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -211,6 +211,9 @@ class Dotfiles(object): if pkg_name in self.packages: home = os.path.join(self.homedir, sub_dir) target = self._fqpn(file, pkg_name=pkg_name) + dirname = os.path.dirname(target) + if not os.path.exists(dirname): + os.makedirs(dirname) else: home = self.homedir target = self._fqpn(file) -- cgit v1.2.3 From f781dcc4a345c88cc08fad8e7bd7990d7b2b9a17 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 31 Jul 2013 20:39:42 -0400 Subject: Add unit test for single-sync feature --- test_dotfiles.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test_dotfiles.py b/test_dotfiles.py index ad4bba6..babe43c 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -254,6 +254,53 @@ class DotfilesTestCase(unittest.TestCase): dotfiles.add([os.path.join(self.homedir, package_file)]) + def test_single_sync(self): + """ + Test syncing a single file in the repo + + The following repo dir exists: + + bashrc + netrc + vimrc + + Syncing only vimrc should have the folowing sync result in home: + + .vimrc -> Dotfiles/vimrc + + """ + + # define the repository contents + repo_files = ( + ('bashrc', False), + ('netrc', False), + ('vimrc', True)) + + # populate the repository + for dotfile, _ in repo_files: + touch(os.path.join(self.repository, dotfile)) + + dotfiles = core.Dotfiles( + homedir=self.homedir, repository=self.repository, + prefix='', ignore=[], externals={}, packages=[], + dry_run=False) + + # sync only certain dotfiles + for dotfile, should_sync in repo_files: + if should_sync: + dotfiles.sync(files=['.%s' % dotfile]) + + # verify home directory contents + for dotfile, should_sync in repo_files: + if should_sync: + self.assertPathEqual( + os.path.join(self.repository, dotfile), + os.path.join(self.homedir, '.%s' % dotfile)) + else: + self.assertFalse(os.path.exists( + os.path.join(self.homedir, dotfile))) + + def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) return suite -- cgit v1.2.3 From 70c4ce33c98ae76fa04ac7e8bc772ec8f93a07dc Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Tue, 25 Jun 2013 17:25:58 -0400 Subject: Update documentation for single-sync operation --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 4f93ec0..2b59069 100644 --- a/README.rst +++ b/README.rst @@ -35,9 +35,10 @@ Interface ``-r, --remove `` Remove dotfile(s) from the repository. -``-s, --sync`` +``-s, --sync `` Update dotfile symlinks. You can overwrite colliding files with ``-f`` or - ``--force``. + ``--force``. All dotfiles are assumed if you do not specify any files to + this command. ``-m, --move`` Move dotfiles repository to another location. -- cgit v1.2.3 From 26c81ce0772efaaf3062baf8db258f7f6def8d98 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Mon, 24 Jun 2013 08:22:54 -0400 Subject: Pass arguments to the sync command along --- dotfiles/cli.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dotfiles/cli.py b/dotfiles/cli.py index 3726e0d..c0984d6 100644 --- a/dotfiles/cli.py +++ b/dotfiles/cli.py @@ -177,10 +177,8 @@ def parse_config(config_file): def dispatch(dotfiles, action, force, args): if action in ['list', 'check']: getattr(dotfiles, action)() - elif action in ['add', 'remove']: + elif action in ['add', 'remove', 'sync']: getattr(dotfiles, action)(args) - elif action == 'sync': - dotfiles.sync(force) elif action == 'move': if len(args) > 1: print("Error: Move cannot handle multiple targets.") -- cgit v1.2.3 From b85f36bc3e3bafe227ca7b3259a67d1683727084 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Mon, 24 Jun 2013 08:23:52 -0400 Subject: Accept an additional files parameter in sync --- dotfiles/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/core.py b/dotfiles/core.py index e4c4ec6..d13c9f4 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -182,7 +182,7 @@ class Dotfiles(object): self.list(verbose=False) - def sync(self, force=False): + def sync(self, files=None, force=False): """Synchronize this repository, creating and updating the necessary symbolic links.""" -- cgit v1.2.3 From db0e9d1130dfd212ca6f2e862b8b9a3b875a4f1b Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Mon, 24 Jun 2013 08:24:20 -0400 Subject: Restrict the sync files to what user specified If the user doesn't specify a set of files to sync then the entire set of dotfiles is assumed. There is an obvious bug here, as user-passed strings are not yet converted to dotfile objects. --- dotfiles/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dotfiles/core.py b/dotfiles/core.py index d13c9f4..8ef0782 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -187,7 +187,11 @@ class Dotfiles(object): """Synchronize this repository, creating and updating the necessary symbolic links.""" - for dotfile in self.dotfiles: + # unless a set of files is specified, operate on all files + if not files: + files = self.dotfiles + + for dotfile in files: dotfile.sync(force) def add(self, files): -- cgit v1.2.3 From a04da147f8e170a64fcec425a77affb8f02424da Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 31 Jul 2013 20:38:06 -0400 Subject: Implement single-sync for specified files This commit allows the user to sync only one (or a subset) of the available dotfiles in the repository. --- dotfiles/core.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dotfiles/core.py b/dotfiles/core.py index 8ef0782..b2e2d0c 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -189,9 +189,14 @@ class Dotfiles(object): # unless a set of files is specified, operate on all files if not files: - files = self.dotfiles + dotfiles = self.dotfiles + else: + files = map(lambda x: os.path.join(self.homedir, x), files) + dotfiles = [x for x in self.dotfiles if x.name in files] + if not dotfiles: + raise Exception("file not found") - for dotfile in files: + for dotfile in dotfiles: dotfile.sync(force) def add(self, files): -- cgit v1.2.3 From 79b52642e63dc90b28f6009a7f314b2152e28e89 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 7 Nov 2013 09:33:56 -0500 Subject: Update sync documentation to indicate optional file argument --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2b59069..16153fe 100644 --- a/README.rst +++ b/README.rst @@ -35,7 +35,7 @@ Interface ``-r, --remove `` Remove dotfile(s) from the repository. -``-s, --sync `` +``-s, --sync [file...]`` Update dotfile symlinks. You can overwrite colliding files with ``-f`` or ``--force``. All dotfiles are assumed if you do not specify any files to this command. -- cgit v1.2.3 From e04b5e6cb601bce8c5e3db1b6dd998158d7d4b42 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 7 Nov 2013 09:34:21 -0500 Subject: Update move documentation to be more concise --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 16153fe..640d174 100644 --- a/README.rst +++ b/README.rst @@ -40,8 +40,9 @@ Interface ``--force``. All dotfiles are assumed if you do not specify any files to this command. -``-m, --move`` - Move dotfiles repository to another location. +``-m, --move `` + Move dotfiles repository to another location, updating all symlinks in the + process. For all commands you can use the ``--dry-run`` option, which will print actions and won't modify anything on your drive. -- cgit v1.2.3