@@ -47,13 +47,15 @@ def generate_descriptive_commit_message(
4747 has_ikraft = any (c ['type' ] == 'ikraft' for c in changes )
4848 has_upphor = any (c ['type' ] in ['upphor' , 'upphor_villkor' ] for c in changes )
4949
50- # Collect sections with titles
50+ # Collect sections with titles and check for article-level changes
5151 ikraft_sections = []
5252 upphor_sections = []
53+ has_article_changes = False
5354
5455 for change in changes :
55- # Skip article-level changes (they represent whole document changes )
56+ # Check if this is an article-level change ( whole document)
5657 if change .get ('source' ) == 'article_tag' :
58+ has_article_changes = True
5759 continue
5860
5961 section_id = change .get ('section_id' )
@@ -99,12 +101,15 @@ def generate_descriptive_commit_message(
99101
100102 if only_upphor :
101103 sections_str = format_section_list (list (only_upphor ))
102- message_parts .append (f"{ sections_str } upphör " )
104+ message_parts .append (f"{ sections_str } upphävs " )
103105
104106 if message_parts :
105107 message = f"{ emoji } { doc_name } : { ', och ' .join (message_parts )} "
108+ elif has_article_changes :
109+ # Only article-level changes (whole document changes)
110+ message = f"{ emoji } { doc_name } träder i kraft och upphävs"
106111 else :
107- message = f"{ emoji } { doc_name } ändringar träder i kraft och upphör "
112+ message = f"{ emoji } { doc_name } ändringar träder i kraft och upphävs "
108113
109114 elif has_ikraft :
110115 # Entry into force
@@ -115,20 +120,26 @@ def generate_descriptive_commit_message(
115120 else :
116121 sections_str = format_section_list (ikraft_sections )
117122 message = f"{ emoji } { doc_name } : { sections_str } träder i kraft"
118- else : # The whole document comes into force
123+ elif has_article_changes :
124+ # Article-level change - whole document comes into force
119125 message = f"{ emoji } { doc_name } träder i kraft"
126+ else :
127+ raise ValueError (f"Ikraft-ändringar hittades för { doc_name } men varken sections eller article-ändringar kunde identifieras" )
120128
121129 else : # has_upphor
122130 # Expiration
123131 emoji = "🚫"
124132 if upphor_sections :
125133 if len (upphor_sections ) == 1 :
126- message = f"{ emoji } { doc_name } : { upphor_sections [0 ]} upphör "
134+ message = f"{ emoji } { doc_name } : { upphor_sections [0 ]} upphävs "
127135 else :
128136 sections_str = format_section_list (upphor_sections )
129- message = f"{ emoji } { doc_name } : { sections_str } upphör"
130- else : # The whole document expires
131- message = f"{ emoji } { doc_name } upphör"
137+ message = f"{ emoji } { doc_name } : { sections_str } upphävs"
138+ elif has_article_changes :
139+ # Article-level change - whole document expires
140+ message = f"{ emoji } { doc_name } upphävs"
141+ else :
142+ raise ValueError (f"Upphor-ändringar hittades för { doc_name } men varken sections eller article-ändringar kunde identifieras" )
132143
133144 return message
134145
0 commit comments