예제 #1
0
    def setUp(self):
        self.executive = Executive()
        self.filesystem = FileSystem()
        self.original_cwd = self.filesystem.getcwd()

        # Set up fresh git repository with one commit.
        self.untracking_checkout_path = self._mkdtemp(
            suffix='-git_unittest_untracking')
        self._run(['git', 'init', self.untracking_checkout_path])
        self._chdir(self.untracking_checkout_path)
        self._write_text_file('foo_file', 'foo')
        self._run(['git', 'add', 'foo_file'])
        self._run(['git', 'commit', '-am', 'dummy commit'])
        self.untracking_scm = Git(cwd=self.untracking_checkout_path,
                                  filesystem=self.filesystem,
                                  executive=self.executive)

        # Then set up a second git repo that tracks the first one.
        self.tracking_git_checkout_path = self._mkdtemp(
            suffix='-git_unittest_tracking')
        self._run([
            'git', 'clone', '--quiet', self.untracking_checkout_path,
            self.tracking_git_checkout_path
        ])
        self._chdir(self.tracking_git_checkout_path)
        self.tracking_scm = Git(cwd=self.tracking_git_checkout_path,
                                filesystem=self.filesystem,
                                executive=self.executive)
예제 #2
0
    def detect_scm_system(self, path, patch_directories=None):
        real_path = self._filesystem.realpath(path)

        if patch_directories == []:
            patch_directories = None

        if SVN.in_working_directory(real_path, executive=self._executive):
            return SVN(cwd=real_path,
                       patch_directories=patch_directories,
                       filesystem=self._filesystem,
                       executive=self._executive)

        if Git.in_working_directory(real_path, executive=self._executive):
            return Git(cwd=real_path,
                       patch_directories=patch_directories,
                       filesystem=self._filesystem,
                       executive=self._executive)

        if StubRepository.in_working_directory(real_path,
                                               filesystem=self._filesystem):
            return StubRepository(cwd=real_path,
                                  patch_directories=patch_directories,
                                  filesystem=self._filesystem,
                                  executive=self._executive)

        return None
 def __init__(self, tool, irc_password):
     SingleServerIRCBot.__init__(self, [(server, port, irc_password)],
                                 nickname, nickname)
     self.git = Git(cwd=tool.scm().checkout_root,
                    filesystem=tool.filesystem,
                    executive=tool.executive)
     self.commands = {
         'help': self.help,
         'quit': self.stop,
     }
예제 #4
0
 def __init__(self, tool, announce_path, irc_password):
     SingleServerIRCBot.__init__(self, [(server, port, irc_password)], nickname, nickname)
     self.announce_path = announce_path
     self.git = Git(cwd=tool.scm().checkout_root, filesystem=tool.filesystem, executive=tool.executive)
     self.commands = {
         'help': self.help,
         'ping': self.ping,
         'quit': self.stop,
     }
     self.last_commit = None
예제 #5
0
파일: host.py 프로젝트: yqjiang/chromium
    def initialize_scm(self):
        # TODO(qyearsley): Refactor this so that scm is initialized
        # when self.scm() is called the first time; put any initialization
        # code in the git module.
        if sys.platform == 'win32':
            self._engage_awesome_windows_hacks()

        cwd = self.filesystem.abspath(self.filesystem.getcwd())
        if Git.in_working_directory(cwd, executive=self.executive):
            self._scm = Git(cwd=cwd, filesystem=self.filesystem, executive=self.executive)
            return

        script_directory = self.filesystem.abspath(
            self.filesystem.dirname(self.filesystem.path_to_module(self.__module__)))
        _log.info('The current directory (%s) is not in a git repo, trying script directory %s.', cwd, script_directory)
        if Git.in_working_directory(script_directory, executive=self.executive):
            self._scm = Git(cwd=script_directory, filesystem=self.filesystem, executive=self.executive)
            return

        raise Exception('FATAL: Failed to find Git repo for %s or %s' % (cwd, script_directory))
예제 #6
0
 def git(self, test_repository):
     return Git(test_repository,
                None,
                executive=self._host.executive,
                filesystem=self._filesystem)
예제 #7
0
 def make_scm(self):
     git = Git(cwd='.',
               executive=MockExecutive(),
               filesystem=MockFileSystem())
     git.read_git_config = lambda *args, **kw: 'MOCKKEY:MOCKVALUE'
     return git
예제 #8
0
 def make_scm(self):
     scm = Git(cwd=".",
               executive=MockExecutive(),
               filesystem=MockFileSystem())
     scm.read_git_config = lambda *args, **kw: "MOCKKEY:MOCKVALUE"
     return scm
예제 #9
0
파일: host.py 프로젝트: yqjiang/chromium
 def scm_for_path(self, path):
     # FIXME: make scm() be a wrapper around this, and clean up the way
     # callers call initialize_scm() (to remove patch_directories) and scm().
     if sys.platform == "win32":
         self._engage_awesome_windows_hacks()
     return Git(cwd=path, executive=self.executive, filesystem=self.filesystem)