Permalink
Browse files

Makes ignore of private files optional

  • Loading branch information...
swinkels committed Oct 31, 2016
1 parent 8ba14a2 commit 883754bb89a935899ec0d9cc1cc96cd20ae21eed
Showing with 59 additions and 1 deletion.
  1. +1 −0 CHANGES.md
  2. +7 −0 README.md
  3. +9 −0 git_cc/common.py
  4. +7 −1 git_cc/sync.py
  5. +2 −0 tests/sync-config/gitcc
  6. 0 tests/sync-config/gitcc-empty
  7. +33 −0 tests/test_sync.py
View
@@ -4,6 +4,7 @@ Changelog for git-cc
1.0.1 (unreleased)
------------------
- gitcc --update only syncs files under ClearCase control.
- Various fixes to work towards Python 3 compatibility.
- Various improvements to the update command:
- only copies files that have changed;
View
@@ -100,6 +100,7 @@ allows you to limit which branches and folders you import from:
include = FolderA|FolderB
exclude = FolderA/sub/folder|FolderB/other/file
users_module_path = users.py
ignore_private_files = False
debug = False
type = UCM
[master]
@@ -132,6 +133,12 @@ from directory .git. But you can also use an absolute users module path.
If you do not specify the users module path in the config file, the ClearCase
user information will be used.
If you make a snapshot of a ClearCase VOB, you copy all the files that are
visible in the view, including view-private files. This might not be what you
want, for example if the VOB contains all kinds of build artifacts. To only
copy the files that are actually under ClearCase control, set the key
'ignore\_private\_files' to True.
## Notes
Can either work with static or dynamic views. I use dynamic at work because
View
@@ -181,6 +181,15 @@ def getUsersModulePath(self):
abs_path = os.path.join(config_dir, path)
return abs_path
def ignorePrivateFiles(self):
"""Return true if and only if private files should not be synced.
If this option holds, only the files that are under ClearCase control
will be synced. Otherwise all the files in the VOB are synced.
"""
return self.getCore('ignore_private_files', False)
def write(file, blob):
_write(file, blob)
View
@@ -126,7 +126,13 @@ def main(cache=False, dry_run=False):
dst_root = GIT_DIR
sync_file = SyncFile() if not dry_run else IgnoreFile()
return ClearCaseSync(src_root, src_dirs, dst_root, sync_file).do_sync()
# determine whether we should sync all files or only the files that are
# under ClearCase control
syncClass = Sync
if cfg.ignorePrivateFiles():
syncClass = ClearCaseSync
return syncClass(src_root, src_dirs, dst_root, sync_file).do_sync()
def output_as_set(command):
View
@@ -0,0 +1,2 @@
[core]
ignore_private_files=True
No changes.
View
@@ -5,6 +5,7 @@
import stat
import unittest
from git_cc.common import GitConfigParser
from git_cc.sync import Sync
from git_cc.sync import SyncFile
from git_cc.sync import ClearCaseSync
@@ -18,6 +19,8 @@
else:
from unittest.mock import Mock
_current_dir = os.path.dirname(__file__)
class CopyTestSuite(unittest.TestCase):
@@ -189,3 +192,33 @@ def test_collect_output(self):
contents = output_as_set([sys.executable, module, directory])
self.assertEqual(set(["a.txt", "b.txt"]), contents)
class SyncConfigTestSuite(unittest.TestCase):
def test_retrieval_of_setting_using_config(self):
gitcc_config_path = self.get_path_to("gitcc")
cfg = GitConfigParser("don't care section", gitcc_config_path)
cfg.read()
self.assertTrue(cfg.ignorePrivateFiles())
def test_retrieval_of_setting_using_empty_config(self):
gitcc_config_path = self.get_path_to("gitcc-empty")
cfg = GitConfigParser("don't care section", gitcc_config_path)
cfg.read()
self.assertFalse(cfg.ignorePrivateFiles())
def get_path_to(self, file_name):
"""Return the path to the given file in directory "sync-config".
Directory "sync-config" is located in the same directory as the current
file.
"""
return os.path.join(_current_dir, "sync-config", file_name)

0 comments on commit 883754b

Please sign in to comment.