@@ -32,7 +32,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
3232< span > Expand source code</ span >
3333</ summary >
3434< 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.
3636# SPDX-License-Identifier: Apache-2.0
3737#
3838"""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
126126 validate_news_file(absolute_file_path)
127127
128128
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:
130130 """Adds a news file if the branch corresponds to an dependency update.
131131
132132 Args:
133133 git: Instance of GitWrapper.
134- news_dir: Relative path to news directory.
134+ news_dir: path to news directory.
135135 """
136136 current_branch = str(git.get_current_branch())
137137 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
147147 )
148148 logger.info(f"Generating a news file with content: {message}...")
149149 return create_news_file(
150- news_dir,
150+ str( news_dir) ,
151151 message,
152152 configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_TYPE),
153153 )
154154
155155
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:
157157 logger.info(f"Committing news file {str(news_file)}...")
158- git.configure_for_github()
158+ if not local:
159+ git.configure_for_github()
159160 git.add(str(news_file))
160161 git.commit("📰 Automatic changes ⚙ Adding news file")
161- git.push()
162- git.pull()
162+ if not local:
163+ git.push()
164+ git.pull()
163165
164166
165167def main() -> None:
@@ -185,8 +187,8 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
185187 except Exception as e:
186188 log_exception(logger, e)
187189 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 )
190192 except Exception as e2:
191193 log_exception(logger, e2)
192194 sys.exit(1)
@@ -245,7 +247,7 @@ <h2 id="returns">Returns</h2>
245247</ details >
246248</ dd >
247249< 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 >
249251</ code > </ dt >
250252< dd >
251253< 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>
254256< dt > < strong > < code > git</ code > </ strong > </ dt >
255257< dd > Instance of GitWrapper.</ dd >
256258< dt > < strong > < code > news_dir</ code > </ strong > </ dt >
257- < dd > Relative path to news directory.</ dd >
259+ < dd > path to news directory.</ dd >
258260</ dl > </ div >
259261< details class ="source ">
260262< summary >
261263< span > Expand source code</ span >
262264</ 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:
264266 """Adds a news file if the branch corresponds to an dependency update.
265267
266268 Args:
267269 git: Instance of GitWrapper.
268- news_dir: Relative path to news directory.
270+ news_dir: path to news directory.
269271 """
270272 current_branch = str(git.get_current_branch())
271273 is_dependency_update, groups = git.is_current_branch_of_type(
@@ -281,7 +283,7 @@ <h2 id="args">Args</h2>
281283 )
282284 logger.info(f"Generating a news file with content: {message}...")
283285 return create_news_file(
284- news_dir,
286+ str( news_dir) ,
285287 message,
286288 configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_TYPE),
287289 )</ code > </ pre >
@@ -319,8 +321,8 @@ <h2 id="args">Args</h2>
319321 except Exception as e:
320322 log_exception(logger, e)
321323 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 )
324326 except Exception as e2:
325327 log_exception(logger, e2)
326328 sys.exit(1)</ code > </ pre >
0 commit comments