예제 #1
0
 def test_resetxp(self):
     # Do some changes
     file_with_changes = os.path.join(self.path_of_testfile, 'python/addxp/example.py_add')
     shutil.copy(file_with_changes, os.path.join(self.repodir, 'example.py'))
     addxp.add('example.py', '/Foo/bar2')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/addxp/example.py_expected1'))
     addxp.add('example.py', '/Foo/bar3')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/addxp/example.py_expected2'))
     # Reset them
     resetxp.reset('example.py', '/Foo/bar2')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/resetxp/example.py_expected1'))
     resetxp.reset('example.py', '/Foo/bar3')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/resetxp/example.py_expected2'))
예제 #2
0
 def test_addxp(self):
     file_with_changes = os.path.join(self.path_of_testfile, 'python/addxp/example.py_add')
     shutil.copy(file_with_changes, os.path.join(self.repodir, 'example.py'))
     addxp.add('example.py', '/Foo/bar2')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/addxp/example.py_expected1'))
     addxp.add('example.py', '/Foo/bar3')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/addxp/example.py_expected2'))
     addxp.add('example.py', '/Foo/bar')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/addxp/example.py_expected3'))
     addxp.add('example.py', '/Foo/__init__')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/addxp/example.py_expected4'))
예제 #3
0
 def test_checkoutxp(self):
     # Do some changes
     file_with_changes = os.path.join(self.path_of_testfile, 'python/addxp/example.py_add')
     shutil.copy(file_with_changes, os.path.join(self.repodir, 'example.py'))
     addxp.add('example.py', '/Foo')
     # Checkout them
     checkoutxp.checkout('example.py', '/Foo/bar2')
     self._assert(self._get_file_from_workingtree('example.py'), self._get_testfile_content('python/checkoutxp/example.py_expected1'))
     checkoutxp.checkout('example.py', '/Foo/bar')
     self._assert(self._get_file_from_workingtree('example.py'), self._get_testfile_content('python/checkoutxp/example.py_expected2'))
     checkoutxp.checkout('example.py', '/Foo/bar3')
     self._assert(self._get_file_from_workingtree('example.py'), self._get_testfile_content('python/checkoutxp/example.py_expected3'))
     checkoutxp.checkout('example.py', '/Foo/__init__')
     self._assert(self._get_file_from_workingtree('example.py'), self._get_testfile_content('python/checkoutxp/example.py_expected4'))
     # Do some changes again
     file_with_changes = os.path.join(self.path_of_testfile, 'python/addxp/example.py_add')
     shutil.copy(file_with_changes, os.path.join(self.repodir, 'example.py'))
     # Checkout all of them
     checkoutxp.checkout('example.py', '/Foo')
     self._assert(self._get_file_from_workingtree('example.py'), self._get_testfile_content('python/checkoutxp/example.py_expected4'))
예제 #4
0
파일: gitxp.py 프로젝트: sickless/gitxp
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import optparse
import os
from libgitxp import gitxp, addxp, delxp

if __name__ == '__main__':
    parser = optparse.OptionParser()
    _, args = parser.parse_args()
    if not args:
        sys.exit(1)
    if len(args) != 2:
        sys.exit(2)

    filename, xpath = gitxp.split_xpath(args[1])
    if args[0] == 'add':
        addxp.add(filename, xpath)
    elif args[0] in ('del', 'delete', 'rm', 'remove'):
        delxp.delete(filename, xpath)
    sys.exit(0)