# Path: test/helper.py
# def call_process(*args, **kwargs):
#     redirected = False
#     if "stdout" not in kwargs and "stderr" not in kwargs:
#         kwargs["stdout"] = PIPE
#         kwargs["stderr"] = PIPE
#         redirected = True
#     exitcode, stdout, stderr = real_call_process(*args, **kwargs)
#     if redirected:
#         sys.stdout.write(stdout)
#         sys.stderr.write(stderr)
#         return exitcode
#     return exitcode, stdout, stderr


import unittest
import os
import sys
import shutil
import rosrepo.git as git
from tempfile import mkdtemp
    from mock import patch
    from unittest.mock import patch
    from StringIO import StringIO
    from io import StringIO
from .helper import call_process
try:
except ImportError:



class GitTest(unittest.TestCase):

    def setUp(self):
        self.upstream_gitdir = mkdtemp()
        self.upstream_git = git.Git(self.upstream_gitdir)
        self.upstream_git.init()
        self.upstream_git.config("user.name", "Unit Tester")
        self.upstream_git.config("user.email", "unittest@example.com")
        with open(os.path.join(self.upstream_gitdir, "hello.txt"), "w") as f:
            f.write("Hello, World!\n")
        self.upstream_git.add("hello.txt")
        self.upstream_git.commit(m="First commit")
        self.upstream_git.tag("ancient")
        with open(os.path.join(self.upstream_gitdir, "hello.txt"), "a") as f:
            f.write("Nice to see you...\n")
        self.upstream_git.add("hello.txt")
        self.upstream_git.commit(m="More text")
        self.upstream_git.checkout("other", b=True)
        with open(os.path.join(self.upstream_gitdir, "other.txt"), "w") as f:
            f.write("One file to rule them all...\n")
        self.upstream_git.add("other.txt")
        self.upstream_git.commit(m="Moar files")
        self.upstream_git.checkout("master")
        with open(os.path.join(self.upstream_gitdir, "other.txt"), "w") as f:
            f.write("I for one welcome our new Git overlords\n")

# Path: test/helper.py
# def call_process(*args, **kwargs):
#     redirected = False
#     if "stdout" not in kwargs and "stderr" not in kwargs:
#         kwargs["stdout"] = PIPE
#         kwargs["stderr"] = PIPE
#         redirected = True
#     exitcode, stdout, stderr = real_call_process(*args, **kwargs)
#     if redirected:
#         sys.stdout.write(stdout)
#         sys.stderr.write(stderr)
#         return exitcode
#     return exitcode, stdout, stderr


# Path: test/test_git.py
import unittest
import os
import sys
import shutil
import rosrepo.git as git
from tempfile import mkdtemp
    from mock import patch
    from unittest.mock import patch
    from StringIO import StringIO
    from io import StringIO
from .helper import call_process

try:
except ImportError:



class GitTest(unittest.TestCase):

    def setUp(self):
        self.upstream_gitdir = mkdtemp()
        self.upstream_git = git.Git(self.upstream_gitdir)
        self.upstream_git.init()
        self.upstream_git.config("user.name", "Unit Tester")
        self.upstream_git.config("user.email", "unittest@example.com")
        with open(os.path.join(self.upstream_gitdir, "hello.txt"), "w") as f:
            f.write("Hello, World!\n")
        self.upstream_git.add("hello.txt")
        self.upstream_git.commit(m="First commit")
        self.upstream_git.tag("ancient")
        with open(os.path.join(self.upstream_gitdir, "hello.txt"), "a") as f:
            f.write("Nice to see you...\n")
        self.upstream_git.add("hello.txt")
        self.upstream_git.commit(m="More text")
        self.upstream_git.checkout("other", b=True)
        with open(os.path.join(self.upstream_gitdir, "other.txt"), "w") as f:
            f.write("One file to rule them all...\n")
        self.upstream_git.add("other.txt")
        self.upstream_git.commit(m="Moar files")
        self.upstream_git.checkout("master")
        with open(os.path.join(self.upstream_gitdir, "other.txt"), "w") as f:
            f.write("I for one welcome our new Git overlords\n")

        self.upstream_git.add("other.txt")