qontract-reconcile 0.10.2.dev196__py3-none-any.whl → 0.10.2.dev197__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev196
3
+ Version: 0.10.2.dev197
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -166,7 +166,7 @@ reconcile/change_owners/README.md,sha256=NEXVw4SioTWTGo9elSQUjqY10RIUoisl4zkzEBv
166
166
  reconcile/change_owners/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
167
167
  reconcile/change_owners/approver.py,sha256=Z3_11vnK2WNOxjEEXVDh0224-_-qbt9d6mBeVE-7fsc,2259
168
168
  reconcile/change_owners/bundle.py,sha256=h30fU-JmLH5a-rCAovpzTeTkkkgZztsZ5A2raee0YuU,5355
169
- reconcile/change_owners/change_log_tracking.py,sha256=6MXABuPbLQwLeFZE_J2SS9Sx23fAVAtPRWKSBxjQrSo,8850
169
+ reconcile/change_owners/change_log_tracking.py,sha256=lRHdC6-sqzUClmoVNq8v5rygAzeQJRxbKbJNDB3YI8E,9499
170
170
  reconcile/change_owners/change_owners.py,sha256=7tESnSX2-psNGPIF63OeK5f-m3iqwanaGjt03FIjWXU,17111
171
171
  reconcile/change_owners/change_types.py,sha256=5eSvS2_npUriq9RN4LdAWdYUiNzF91K1pDUEVYDIQ4k,32023
172
172
  reconcile/change_owners/changes.py,sha256=YTqwUYutQ6JVSSYmC2Ph5ROCiVix42Vnzy47-i57z4Q,18119
@@ -809,7 +809,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
809
809
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
810
810
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
811
811
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
812
- qontract_reconcile-0.10.2.dev196.dist-info/METADATA,sha256=uRgPJGf2hvsWk3jhJUQz581Qv8WkL4Q4R70sX5tYxSo,24555
813
- qontract_reconcile-0.10.2.dev196.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
814
- qontract_reconcile-0.10.2.dev196.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
815
- qontract_reconcile-0.10.2.dev196.dist-info/RECORD,,
812
+ qontract_reconcile-0.10.2.dev197.dist-info/METADATA,sha256=rege7bsatzPbGGlyw26PU4oHYZuVuqVjfy8pKkGr4Sk,24555
813
+ qontract_reconcile-0.10.2.dev197.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
814
+ qontract_reconcile-0.10.2.dev197.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
815
+ qontract_reconcile-0.10.2.dev197.dist-info/RECORD,,
@@ -2,6 +2,9 @@ import logging
2
2
  from collections import defaultdict
3
3
  from collections.abc import Callable
4
4
 
5
+ from gitlab.v4.objects import (
6
+ ProjectCommit,
7
+ )
5
8
  from pydantic import BaseModel
6
9
 
7
10
  from reconcile.change_owners.bundle import (
@@ -23,7 +26,6 @@ from reconcile.typed_queries.jenkins import get_jenkins_configs
23
26
  from reconcile.typed_queries.namespaces import get_namespaces
24
27
  from reconcile.utils import gql
25
28
  from reconcile.utils.defer import defer
26
- from reconcile.utils.gitlab_api import MRState
27
29
  from reconcile.utils.runtime.integration import (
28
30
  PydanticRunParams,
29
31
  QontractReconcileIntegration,
@@ -32,6 +34,7 @@ from reconcile.utils.state import init_state
32
34
 
33
35
  QONTRACT_INTEGRATION = "change-log-tracking"
34
36
  BUNDLE_DIFFS_OBJ = "bundle-diffs.json"
37
+ DEFAULT_MERGE_COMMIT_PREFIX = "Merge branch '"
35
38
 
36
39
 
37
40
  class ChangeLogItem(BaseModel):
@@ -66,6 +69,25 @@ class ChangeLogIntegration(QontractReconcileIntegration[ChangeLogIntegrationPara
66
69
  def name(self) -> str:
67
70
  return QONTRACT_INTEGRATION
68
71
 
72
+ @staticmethod
73
+ def _get_description_from_commit(commit: ProjectCommit) -> str:
74
+ """
75
+ Extracts the description from a commit message.
76
+ Skip the default merge commit template.
77
+ Merge branch '%{source_branch}' into '%{target_branch}'
78
+ https://gitlab.cee.redhat.com/help/user/project/merge_requests/commit_templates#default-template-for-merge-commits
79
+
80
+ :param commit: ProjectCommit object from GitLab API
81
+ :return: Extracted description or an empty string if not found
82
+ """
83
+ for message in commit.message.splitlines():
84
+ trimmed_message = message.strip()
85
+ if trimmed_message and not trimmed_message.startswith(
86
+ DEFAULT_MERGE_COMMIT_PREFIX
87
+ ):
88
+ return trimmed_message
89
+ return ""
90
+
69
91
  @defer
70
92
  def run(
71
93
  self,
@@ -118,16 +140,10 @@ class ChangeLogIntegration(QontractReconcileIntegration[ChangeLogIntegrationPara
118
140
 
119
141
  logging.info(f"Processing commit {commit}")
120
142
  gl_commit = gl.project.commits.get(commit)
121
- merged_at = max(
122
- mr["merged_at"]
123
- for mr in gl_commit.merge_requests()
124
- if mr["state"] == MRState.MERGED
125
- and mr["target_branch"] == gl.project.default_branch
126
- )
127
143
  change_log_item = ChangeLogItem(
128
144
  commit=commit,
129
- merged_at=merged_at,
130
- description=gl_commit.message.split("\n")[2],
145
+ merged_at=gl_commit.committed_date,
146
+ description=self._get_description_from_commit(gl_commit),
131
147
  )
132
148
  change_log.items.append(change_log_item)
133
149
  obj = diff_state.get(key, None)