示例#1
0
    def test_opt_worktree(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            out = cmdout(giftp,
                         '--git-dir=' + supergitp,
                         '--work-tree=' + tmpdir,
                         "log",
                         "-n1",
                         cwd=".")

        self.assertEqual([
            'commit c3954c897dfe40a5b99b7145820eeb227210265c',
            'Author: drdr xp <*****@*****.**>',
            'Date:   Fri Jan 24 15:01:01 2020 +0800', '', '    add super'
        ], out)

        with tempfile.TemporaryDirectory() as tmpdir:
            out = cmdout(giftp,
                         '--git-dir=' + supergitp,
                         '--work-tree=' + tmpdir,
                         "diff",
                         "--name-only",
                         "--relative",
                         "HEAD",
                         cwd=".")

        self.assertEqual(['.gift', 'imsuperman'], out)
示例#2
0
    def test_opt_paging(self):
        out = cmdout(giftp, "gift-debug", cwd=superp)
        self.assertIn('paging: null', '\n'.join(out))

        out = cmdout(giftp, '-p', "gift-debug", cwd=superp)
        self.assertIn('paging: true', '\n'.join(out))

        out = cmdout(giftp, '--paginate', "gift-debug", cwd=superp)
        self.assertIn('paging: true', '\n'.join(out))

        out = cmdout(giftp, '--no-pager', "gift-debug", cwd=superp)
        self.assertIn('paging: false', '\n'.join(out))
示例#3
0
    def test_opt_exec_path(self):
        rst = cmd0(giftp, "--exec-path")
        self.assertEqual(execpath, rst)

        rst = cmd0(giftp, "--exec-path", "--exec-path=" + execpath)
        self.assertEqual(execpath, rst)

        rst = cmd0(giftp, "--exec-path=" + execpath, "--exec-path")
        self.assertEqual(execpath, rst)

        out = cmdout(giftp,
                     "--exec-path=/foo/",
                     "-p",
                     "gift-debug",
                     cwd=superp)
        self.assertEqual([
            'gift-debug',
            'additional: {}',
            'informative_cmds: {}',
            'opt:',
            '  bare: false',
            '  confkv: []',
            '  exec_path: /foo/',
            '  git_dir: null',
            '  namespace: null',
            '  no_replace_objects: false',
            '  paging: true',
            '  startpath: []',
            '  super_prefix: null',
            '  work_tree: null',
            '',
            'evaluated cwd: ' + this_base + '/testdata/super',
            'evaluated git_dir: None',
            'evaluated working_dir: None',
        ], out)
示例#4
0
    def test_opt_big_c(self):

        with tempfile.TemporaryDirectory() as tmpdir:
            out = cmdout(giftp,
                         '-C',
                         this_base,
                         '--git-dir=' + pjoin('testdata', 'supergit'),
                         '--work-tree=' + pjoin("testdata", 'super'),
                         "ls-files",
                         cwd=tmpdir)

        self.assertEqual(['.gift', 'imsuperman'], out)
示例#5
0
    def test_opt_git_dir(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            out = cmdout(giftp,
                         '--git-dir=' + supergitp,
                         "log",
                         "-n1",
                         cwd=tmpdir)

        self.assertEqual([
            'commit c3954c897dfe40a5b99b7145820eeb227210265c',
            'Author: drdr xp <*****@*****.**>',
            'Date:   Fri Jan 24 15:01:01 2020 +0800', '', '    add super'
        ], out)
示例#6
0
    def test_ddstack(self):
        script = '''
import sys;
import logging;
import k3handy;
logging.basicConfig(stream=sys.stdout, level=logging.{level});
def foo(): k3handy.ddstack("123");
foo()
'''
        got = k3handy.cmdout(
            'python', '-c',
            script.format(level="DEBUG")
        )
        self.assertEqual([
            "DEBUG:k3handy.cmd:stack: 6 foo ",
            "DEBUG:k3handy.cmd:stack: 7 <module> ",
        ], got)

        got = k3handy.cmdout(
            'python', '-c',
            script.format(level="INFO")
        )
        self.assertEqual([], got)
示例#7
0
 def test_opt_help(self):
     out = cmdout(giftp, "--help", cwd=superp)
     self.assertIn(
         'These are common Git commands used in various situations:', out)
     self.assertIn('Gift extended command:', out)
     self.assertIn('gift clone --sub <url>@<branch> <dir>', out)
示例#8
0
 def test_opt_version(self):
     out = cmdout(giftp, "--version", cwd=superp)
     self.assertEqual('gift version 0.1.0', out[0])
     self.assertEqual(2, len(out))