Esempio n. 1
0
 def __generate_data_points_for_last_commits(self, log: Logger, git: GitUtils):
     last_data_points = {'metrics': {}}
     for commit in list(git.generate_annotated_commits_with_details(STATS_REF_NAME))[::-1]:
         decoded_stats = JSONDecoder().decode(commit['note'])
         current_data_points = self.__generate_data_point_for_commit(decoded_stats, commit, log)
         if not current_data_points['metrics'] == last_data_points['metrics']:
             last_data_points = current_data_points
             yield last_data_points
Esempio n. 2
0
    def test_generate_annotated_commits_with_details(self):
        git_log_cmd = 'log --show-notes=test-ref -n {0} --pretty=format:"hash,%H,shorthash,%h,commiter,%an <%ae>,date,%at|__NOTE__|%N"'

        git_executor = MockGitExecutor()\
            .expect_call(git_log_cmd.format(100), ['key01,value01,key02,value02|__NOTE__|note01', 'key11,value11,key12,value12|__NOTE__|note02'])

        git_utils = GitUtils(git_executor)
        commits_generator = git_utils.generate_annotated_commits_with_details('test-ref', 100)

        self.assertDictEqual({'note': 'note01', 'key01':'value01', 'key02': 'value02'}, next(commits_generator))
        self.assertDictEqual({'note': 'note02', 'key11':'value11', 'key12': 'value12'}, next(commits_generator))
        self.assertIteratorFinished(commits_generator)
Esempio n. 3
0
 def __generate_data_points_for_last_commits(self, log: Logger,
                                             git: GitUtils):
     last_data_points = {'metrics': {}}
     for commit in list(
             git.generate_annotated_commits_with_details(
                 STATS_REF_NAME))[::-1]:
         decoded_stats = JSONDecoder().decode(commit['note'])
         current_data_points = self.__generate_data_point_for_commit(
             decoded_stats, commit, log)
         if not current_data_points['metrics'] == last_data_points[
                 'metrics']:
             last_data_points = current_data_points
             yield last_data_points