Example #1
0
 def test_delxp(self):
     delxp.delete('example.py', '/Foo/bar')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/delxp/example.py_expected1'))
     delxp.delete('example.py', '/Foo/bar2')
     self._assert(self.repo.git.show(':example.py'), self._get_testfile_content('python/delxp/example.py_expected2'))
     delxp.delete('example.py', '/Foo')
     self._assert(self.repo.git.show(':example.py'), '')
Example #2
0
#!/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)