From 13cf54aee19b0d7fa269b503c3d6f328e5fc0552 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 5 Oct 2011 09:27:08 -0400 Subject: Fix bug when syncing an unmanaged directory symlink Closes #2 --- dotfiles/core.py | 2 +- test_dotfiles.py | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/dotfiles/core.py b/dotfiles/core.py index e99811b..dc7893c 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -38,7 +38,7 @@ class Dotfile(object): if not force: print "Skipping \"%s\", use --force to override" % self.basename return - if os.path.isdir(self.name): + if os.path.isdir(self.name) and not os.path.islink(self.name): shutil.rmtree(self.name) else: os.remove(self.name) diff --git a/test_dotfiles.py b/test_dotfiles.py index 360d7db..bb54578 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -21,7 +21,7 @@ class DotfilesTestCase(unittest.TestCase): self.home = tempfile.mkdtemp() - # create a repository for the tests to use + # Create a repository for the tests to use. self.repo = os.path.join(self.home, 'Dotfiles') os.mkdir(self.repo) @@ -62,7 +62,7 @@ class DotfilesTestCase(unittest.TestCase): dotfiles.sync() - # make sure sync() did the right thing + # Make sure sync() did the right thing. self.assertEqual( os.path.realpath(os.path.join(self.home, '.bashrc')), os.path.join(self.repo, 'bashrc')) @@ -76,6 +76,41 @@ class DotfilesTestCase(unittest.TestCase): os.path.realpath(os.path.join(self.home, '.bashrc')), os.path.join(target, 'bashrc')) + def test_sync_unmanaged_directory_symlink(self): + """Test a forced sync on a directory symlink. + + A bug was reported where a user wanted to replace a dotfile repository + with an other one. They had a .vim directory in their home directory + which was obviously also a symbolic link. This caused: + + OSError: Cannot call rmtree on a symbolic link + """ + + # Create a dotfile symlink to some directory + os.mkdir(os.path.join(self.home, 'vim')) + os.symlink(os.path.join(self.home, 'vim'), + os.path.join(self.home, '.vim')) + + # Create a vim directory in the repository. This will cause the above + # symlink to be overwritten on sync. + os.mkdir(os.path.join(self.repo, 'vim')) + + # Make sure the symlink points to the correct location. + self.assertEqual( + os.path.realpath(os.path.join(self.home, '.vim')), + os.path.join(self.home, 'vim')) + + dotfiles = core.Dotfiles( + home=self.home, repo=self.repo, prefix='', + ignore=[], externals={}) + + dotfiles.sync(force=True) + + # The symlink should now point to the directory in the repository. + self.assertEqual( + os.path.realpath(os.path.join(self.home, '.vim')), + os.path.join(self.repo, 'vim')) + def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) -- cgit v1.2.3 From afed3639f6473da42d505fa46935a5820095c180 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 5 Oct 2011 09:39:20 -0400 Subject: Add HISTORY.rst to keep a log of changes for each release --- HISTORY.rst | 2 ++ MANIFEST.in | 2 +- setup.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 HISTORY.rst diff --git a/HISTORY.rst b/HISTORY.rst new file mode 100644 index 0000000..7e21346 --- /dev/null +++ b/HISTORY.rst @@ -0,0 +1,2 @@ +History +------- diff --git a/MANIFEST.in b/MANIFEST.in index 0c73842..3df5357 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include README.rst LICENSE +include HISTORY.rst README.rst LICENSE diff --git a/setup.py b/setup.py index df99c5a..e11410b 100755 --- a/setup.py +++ b/setup.py @@ -25,7 +25,8 @@ if sys.argv[-1] == "test": setup(name='dotfiles', version=__version__, description='Easily manage your dotfiles', - long_description=open('README.rst').read(), + long_description=open('README.rst').read() + '\n\n' + + open('HISTORY.rst').read(), author='Jon Bernard', author_email='jbernard@tuxion.com', url='https://github.com/jbernard/dotfiles', -- cgit v1.2.3 From 055b0decea6066921590c17e1eb0279e2706bb69 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 5 Oct 2011 18:51:24 -0400 Subject: Add AUTHORS.rst to credit contributers --- AUTHORS.rst | 12 ++++++++++++ MANIFEST.in | 2 +- README.rst | 6 ++++-- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 AUTHORS.rst diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..4bdcc0b --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,12 @@ +Dotfiles is written and maintained by Jon Bernard and various contributors: + +Development Lead +```````````````` + +- Jon Bernard + + +Patches and Suggestions +``````````````````````` + +- Anaƫl Beutot diff --git a/MANIFEST.in b/MANIFEST.in index 3df5357..ec3e59e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include HISTORY.rst README.rst LICENSE +include HISTORY.rst README.rst LICENSE AUTHORS.rst diff --git a/README.rst b/README.rst index 5e959fd..d717ff9 100644 --- a/README.rst +++ b/README.rst @@ -151,7 +151,9 @@ GPL License. :: Contribute ---------- -If you'd like to contribute, simply fork `the repository`_, commit your changes -and send a pull request. +If you'd like to contribute, simply fork `the repository`_, commit your +changes to the **develop** branch (or branch off of it), and send a pull +request. Make sure you add yourself to AUTHORS_. .. _`the repository`: https://github.com/jbernard/dotfiles +.. _AUTHORS: https://github.com/jbernard/dotfiles/blob/master/AUTHORS -- cgit v1.2.3 From 731ca5b6fb3c397039b91b5716c56d51f4a31856 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 5 Oct 2011 19:15:13 -0400 Subject: Bump version number for version 0.4.2 release --- dotfiles/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/core.py b/dotfiles/core.py index dc7893c..f3241c9 100644 --- a/dotfiles/core.py +++ b/dotfiles/core.py @@ -11,7 +11,7 @@ import os import shutil -__version__ = '0.4.1' +__version__ = '0.4.2' __author__ = "Jon Bernard" __license__ = "GPL" -- cgit v1.2.3 From bf73e1f7d50506ff6ac58e5f70e1ac9f0412e1d3 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 5 Oct 2011 19:15:33 -0400 Subject: Update history for version 0.4.2 release --- HISTORY.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 7e21346..64c4346 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,2 +1,7 @@ History ------- + +0.4.2 ++++++ + +* Fix bug when syncing an unmanaged directory symlink -- cgit v1.2.3