コード例 #1
0
ファイル: review.py プロジェクト: everestmz/l2tdevtools
  def InitializeHelpers(self):
    """Initializes the helpers.

    Returns:
      bool: True if the helper initialization was successful.
    """
    project_path = os.path.abspath(self._project_path)

    self._project_helper = project.ProjectHelper(project_path)

    self._project_name = self._project_helper.project_name
    if not self._project_name:
      print('{0:s} aborted - unable to determine project name.'.format(
          self._command.title()))  # yapf: disable
      return False

    if self._project_name in ('artifacts', 'artifacts-kb'):
      github_organization = 'ForensicArtifacts'
    elif self._project_name in (
        'dtfabric', 'dtformats', 'esedb-kb', 'winevt-kb', 'winreg-kb'):
      github_organization = 'libyal'
    else:
      github_organization = 'log2timeline'

    self._git_repo_url = b'https://github.com/{0:s}/{1:s}.git'.format(
        github_organization, self._project_name)

    self._git_helper = git.GitHelper(self._git_repo_url)

    self._github_helper = github.GitHubHelper(
        github_organization, self._project_name)

    return True
コード例 #2
0
ファイル: github.py プロジェクト: kiddinn/l2tdevtools
    def testQueryUser(self):
        """Tests the QueryUser function."""
        helper = github.GitHubHelper(organization='test',
                                     project='test_project')
        helper._url_lib_helper = test_lib.TestURLLibHelper()

        result = helper.QueryUser('test_user')
        self.assertIsNone(result)
コード例 #3
0
ファイル: github.py プロジェクト: kiddinn/l2tdevtools
    def testGetForkGitRepoUrl(self):
        """Tests the GetForkGitRepoUrl function."""
        helper = github.GitHubHelper(organization='test',
                                     project='test_project')
        helper._url_lib_helper = test_lib.TestURLLibHelper()

        expected_url = 'https://github.com/test_user/test_project.git'
        url = helper.GetForkGitRepoUrl('test_user')
        self.assertEqual(url, expected_url)
コード例 #4
0
ファイル: github.py プロジェクト: kiddinn/l2tdevtools
    def testCreatePullRequestReview(self):
        """Tests the CreatePullRequestReview function."""
        helper = github.GitHubHelper(organization='test',
                                     project='test_project')
        helper._url_lib_helper = test_lib.TestURLLibHelper()

        result = helper.CreatePullRequestReview(4, 'TOKEN', ['Onager'])

        self.assertTrue(result)
コード例 #5
0
ファイル: github.py プロジェクト: kiddinn/l2tdevtools
    def testCreatePullRequest(self):
        """Tests the CreatePullRequest function."""
        create_result = json.dumps({"number": 1})

        helper = github.GitHubHelper(organization='test',
                                     project='test_project')
        helper._url_lib_helper = test_lib.TestURLLibHelper(
            result=create_result)

        result = helper.CreatePullRequest('TOKEN', 'origin', 'title', 'body')
        self.assertEqual(result, 1)
コード例 #6
0
ファイル: review.py プロジェクト: kiddinn/l2tdevtools
    def InitializeHelpers(self):
        """Initializes the helpers.

    Returns:
      bool: True if the helper initialization was successful.
    """
        project_path = os.path.abspath(self._project_path)

        self._project_helper = project.ProjectHelper(project_path)

        self._project_name = self._project_helper.project_name
        if not self._project_name:
            print('{0:s} aborted - unable to determine project name.'.format(
                self._command.title()))  # yapf: disable
            return False

        project_definition = self._project_helper.ReadDefinitionFile()

        self._github_organization = None
        if project_definition.homepage_url.startswith('https://github.com/'):
            self._github_organization = project_definition.homepage_url[
                len('https://github.com/'):]

            self._github_organization, _, _ = self._github_organization.partition(
                '/')

        if not self._github_organization:
            print('{0:s} aborted - unable to determine GitHub organization.'.
                  format(self._command.title()))
            return False

        self._git_repo_url = 'https://github.com/{0:s}/{1:s}.git'.format(
            self._github_organization, self._project_name)

        self._git_helper = git.GitHelper(self._git_repo_url)

        self._github_helper = github.GitHubHelper(self._github_organization,
                                                  self._project_name)

        return True