@@ -32,7 +32,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
32
32
< span > Expand source code</ span >
33
33
</ summary >
34
34
< pre > < code class ="python "> #
35
- # Copyright (C) 2020-2021 Arm. All rights reserved.
35
+ # Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors . All rights reserved.
36
36
# SPDX-License-Identifier: Apache-2.0
37
37
#
38
38
"""Checks if valid news files are created for changes in the project."""
@@ -126,12 +126,12 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
126
126
validate_news_file(absolute_file_path)
127
127
128
128
129
- def generate_news_file(git: GitWrapper, news_dir: str ) -> pathlib.Path:
129
+ def generate_news_file(git: GitWrapper, news_dir: pathlib.Path ) -> pathlib.Path:
130
130
"""Adds a news file if the branch corresponds to an dependency update.
131
131
132
132
Args:
133
133
git: Instance of GitWrapper.
134
- news_dir: Relative path to news directory.
134
+ news_dir: path to news directory.
135
135
"""
136
136
current_branch = str(git.get_current_branch())
137
137
is_dependency_update, groups = git.is_current_branch_of_type(
@@ -147,19 +147,21 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
147
147
)
148
148
logger.info(f"Generating a news file with content: {message}...")
149
149
return create_news_file(
150
- news_dir,
150
+ str( news_dir) ,
151
151
message,
152
152
configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_TYPE),
153
153
)
154
154
155
155
156
- def _commit_news_file(git: GitWrapper, news_file: pathlib.Path) -> None:
156
+ def _commit_news_file(git: GitWrapper, news_file: pathlib.Path, local: bool ) -> None:
157
157
logger.info(f"Committing news file {str(news_file)}...")
158
- git.configure_for_github()
158
+ if not local:
159
+ git.configure_for_github()
159
160
git.add(str(news_file))
160
161
git.commit("📰 Automatic changes ⚙ Adding news file")
161
- git.push()
162
- git.pull()
162
+ if not local:
163
+ git.push()
164
+ git.pull()
163
165
164
166
165
167
def main() -> None:
@@ -185,8 +187,8 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
185
187
except Exception as e:
186
188
log_exception(logger, e)
187
189
try:
188
- news_file = generate_news_file(git, absolute_news_dir )
189
- _commit_news_file(git, news_file)
190
+ news_file = generate_news_file(git, git.get_corresponding_path(pathlib.Path(news_dir)) )
191
+ _commit_news_file(git, news_file, args.local )
190
192
except Exception as e2:
191
193
log_exception(logger, e2)
192
194
sys.exit(1)
@@ -245,7 +247,7 @@ <h2 id="returns">Returns</h2>
245
247
</ details >
246
248
</ dd >
247
249
< dt id ="continuous_delivery_scripts.assert_news.generate_news_file "> < code class ="name flex ">
248
- < span > def < span class ="ident "> generate_news_file</ span > </ span > (< span > git: < a title ="continuous_delivery_scripts.utils.git_helpers.GitWrapper " href ="utils/git_helpers.html#continuous_delivery_scripts.utils.git_helpers.GitWrapper "> GitWrapper</ a > , news_dir: str ) ‑> pathlib.Path</ span >
250
+ < span > def < span class ="ident "> generate_news_file</ span > </ span > (< span > git: < a title ="continuous_delivery_scripts.utils.git_helpers.GitWrapper " href ="utils/git_helpers.html#continuous_delivery_scripts.utils.git_helpers.GitWrapper "> GitWrapper</ a > , news_dir: pathlib.Path ) ‑> pathlib.Path</ span >
249
251
</ code > </ dt >
250
252
< dd >
251
253
< div class ="desc "> < p > Adds a news file if the branch corresponds to an dependency update.</ p >
@@ -254,18 +256,18 @@ <h2 id="args">Args</h2>
254
256
< dt > < strong > < code > git</ code > </ strong > </ dt >
255
257
< dd > Instance of GitWrapper.</ dd >
256
258
< dt > < strong > < code > news_dir</ code > </ strong > </ dt >
257
- < dd > Relative path to news directory.</ dd >
259
+ < dd > path to news directory.</ dd >
258
260
</ dl > </ div >
259
261
< details class ="source ">
260
262
< summary >
261
263
< span > Expand source code</ span >
262
264
</ summary >
263
- < pre > < code class ="python "> def generate_news_file(git: GitWrapper, news_dir: str ) -> pathlib.Path:
265
+ < pre > < code class ="python "> def generate_news_file(git: GitWrapper, news_dir: pathlib.Path ) -> pathlib.Path:
264
266
"""Adds a news file if the branch corresponds to an dependency update.
265
267
266
268
Args:
267
269
git: Instance of GitWrapper.
268
- news_dir: Relative path to news directory.
270
+ news_dir: path to news directory.
269
271
"""
270
272
current_branch = str(git.get_current_branch())
271
273
is_dependency_update, groups = git.is_current_branch_of_type(
@@ -281,7 +283,7 @@ <h2 id="args">Args</h2>
281
283
)
282
284
logger.info(f"Generating a news file with content: {message}...")
283
285
return create_news_file(
284
- news_dir,
286
+ str( news_dir) ,
285
287
message,
286
288
configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_TYPE),
287
289
)</ code > </ pre >
@@ -319,8 +321,8 @@ <h2 id="args">Args</h2>
319
321
except Exception as e:
320
322
log_exception(logger, e)
321
323
try:
322
- news_file = generate_news_file(git, absolute_news_dir )
323
- _commit_news_file(git, news_file)
324
+ news_file = generate_news_file(git, git.get_corresponding_path(pathlib.Path(news_dir)) )
325
+ _commit_news_file(git, news_file, args.local )
324
326
except Exception as e2:
325
327
log_exception(logger, e2)
326
328
sys.exit(1)</ code > </ pre >
0 commit comments