Example #1
0
 def exec_command(cls, command, base_dir, debug_output=True):
     Logger.msg('>> ' + ' '.join(command))
     try:
         if debug_output:
             proc = _subprocess.Popen(command, cwd=base_dir)
         else:
             proc = _subprocess.Popen(command,
                                      cwd=base_dir,
                                      stdout=open(_os.devnull, 'w'),
                                      stderr=_subprocess.STDOUT)
         proc.communicate()
         return_code = proc.wait()
         if return_code != 0:
             raise ShellError('Command \'%s\' failed!' % command)
     except (OSError, IOError) as err:
         raise ShellError(str(err))
     return
Example #2
0
 def exec_command(cls, command, base_dir, debug_output=True):
     Logger.msg('>> ' + ' '.join(command))
     try:
         if debug_output:
             proc = _subprocess.Popen(
                 command,
                 cwd=base_dir)
         else:
             proc = _subprocess.Popen(
                 command,
                 cwd=base_dir,
                 stdout=open(_os.devnull, 'w'),
                 stderr=_subprocess.STDOUT)
         proc.communicate()
         return_code = proc.wait()
         if return_code != 0:
             raise ShellError('Command \'%s\' failed!' % command)
     except (OSError, IOError) as err:
         raise ShellError(str(err))
     return
Example #3
0
def run_tests():
    test_dir = _os.path.join(_os.getcwd(), 'testing-ground')
    git_wrapper_tests = GitWrapperTestSuite(test_dir).get_test_suite()
    test_output = _cStringIO.StringIO()

    runner = _unittest.TextTestRunner(
        stream=test_output,
        verbosity=2)
    runner.run(git_wrapper_tests)

    Logger.msg('\n')
    Logger.msg('#' * 80)
    Logger.msg(test_output.getvalue())
    Logger.msg('#' * 80)
Example #4
0
    def _exec_status(self):
        if not self._is_client_initialized():
            raise CommandHandlerError(
                'Error: Uninitialized client, ' +
                'please run init to initialize the client first')

        # Parse the manifest XML
        self._parse_manifest_xml()

        # Get the client spec name from client info
        client = self._get_client_spec(self._get_client_info())

        # Process each repo in the Client Spec
        for repo in client.repo_list:
            git = GitWrapper(_os.path.join(self._current_dir,
                                           repo.destination))
            Logger.msg('####################################################')
            Logger.msg('Repo: ' + repo.destination)
            Logger.msg('Remote URL: ' + repo.url)
            git.update_index()
            current_branch = git.get_current_branch()
            dirty = False

            if current_branch is None:
                current_branch = 'Detached HEAD'

            if current_branch != repo.branch:
                Logger.msg('Original Branch: ' + repo.branch)
                Logger.msg('Current Branch: ' + current_branch + '\n')
            else:
                Logger.msg('Branch: ' + repo.branch + '\n')

            untracked_files = git.get_untracked_files()
            if len(untracked_files) != 0:
                Logger.msg('Untracked Files: \n' + '\n'.join(untracked_files) +
                           '\n')
                dirty = True

            unstaged_files = git.get_unstaged_files()
            if len(unstaged_files) != 0:
                Logger.msg('Unstaged Files: \n' + '\n'.join(unstaged_files) +
                           '\n')
                dirty = True

            uncommitted_staged_files = git.get_uncommitted_staged_files()
            if len(uncommitted_staged_files) != 0:
                Logger.msg('Uncommitted Changes: \n' +
                           '\n'.join(uncommitted_staged_files) + '\n')
                dirty = True

            if not dirty:
                Logger.msg('No uncommitted changes')
        Logger.msg('####################################################')
        return
Example #5
0
 def _display_help_status(self):
     Logger.msg(self._status_command_parser.format_help())
     return
Example #6
0
 def _display_help_init(self):
     Logger.msg(self._init_command_parser.format_help())
     return
Example #7
0
 def _print_message(self, message, file_handle=None):
     if message:
         if file_handle is None:
             Logger.error('Writing to stderr - file is None')
         Logger.msg(message)
     return
Example #8
0
 def _display_help_status(self):
     Logger.msg(self._status_command_parser.format_help())
     return
Example #9
0
 def _display_help_init(self):
     Logger.msg(self._init_command_parser.format_help())
     return
Example #10
0
 def _print_message(self, message, file_handle=None):
     if message:
         if file_handle is None:
             Logger.error('Writing to stderr - file is None')
         Logger.msg(message)
     return
Example #11
0
    def _exec_status(self):
        if not self._is_client_initialized():
            raise CommandHandlerError(
                'Error: Uninitialized client, ' +
                'please run init to initialize the client first')

        # Parse the manifest XML
        self._parse_manifest_xml()

        # Get the client spec name from client info
        client = self._get_client_spec(self._get_client_info())

        # Process each repo in the Client Spec
        for repo in client.repo_list:
            git = GitWrapper(
                _os.path.join(self._current_dir,
                              repo.destination))
            Logger.msg('####################################################')
            Logger.msg('Repo: ' + repo.destination)
            Logger.msg('Remote URL: ' + repo.url)
            git.update_index()
            current_branch = git.get_current_branch()
            dirty = False

            if current_branch is None:
                current_branch = 'Detached HEAD'

            if current_branch != repo.branch:
                Logger.msg('Original Branch: ' + repo.branch)
                Logger.msg('Current Branch: ' + current_branch + '\n')
            else:
                Logger.msg('Branch: ' + repo.branch + '\n')

            untracked_files = git.get_untracked_files()
            if len(untracked_files) != 0:
                Logger.msg(
                    'Untracked Files: \n' + '\n'.join(untracked_files) + '\n')
                dirty = True

            unstaged_files = git.get_unstaged_files()
            if len(unstaged_files) != 0:
                Logger.msg(
                    'Unstaged Files: \n' + '\n'.join(unstaged_files) + '\n')
                dirty = True

            uncommitted_staged_files = git.get_uncommitted_staged_files()
            if len(uncommitted_staged_files) != 0:
                Logger.msg('Uncommitted Changes: \n' +
                           '\n'.join(uncommitted_staged_files) + '\n')
                dirty = True

            if not dirty:
                Logger.msg('No uncommitted changes')
        Logger.msg('####################################################')
        return