@@ -93,12 +93,12 @@ def validate_news_files(git: GitWrapper, root_dir: str, news_dir: str) -> None:
9393 validate_news_file (absolute_file_path )
9494
9595
96- def generate_news_file (git : GitWrapper , news_dir : str ) -> pathlib .Path :
96+ def generate_news_file (git : GitWrapper , news_dir : pathlib . Path ) -> pathlib .Path :
9797 """Adds a news file if the branch corresponds to an dependency update.
9898
9999 Args:
100100 git: Instance of GitWrapper.
101- news_dir: Relative path to news directory.
101+ news_dir: path to news directory.
102102 """
103103 current_branch = str (git .get_current_branch ())
104104 is_dependency_update , groups = git .is_current_branch_of_type (
@@ -114,19 +114,21 @@ def generate_news_file(git: GitWrapper, news_dir: str) -> pathlib.Path:
114114 )
115115 logger .info (f"Generating a news file with content: { message } ..." )
116116 return create_news_file (
117- news_dir ,
117+ str ( news_dir ) ,
118118 message ,
119119 configuration .get_value (ConfigurationVariable .DEPENDENCY_UPDATE_NEWS_TYPE ),
120120 )
121121
122122
123- def _commit_news_file (git : GitWrapper , news_file : pathlib .Path ) -> None :
123+ def _commit_news_file (git : GitWrapper , news_file : pathlib .Path , local : bool ) -> None :
124124 logger .info (f"Committing news file { str (news_file )} ..." )
125- git .configure_for_github ()
125+ if not local :
126+ git .configure_for_github ()
126127 git .add (str (news_file ))
127128 git .commit ("📰 Automatic changes ⚙ Adding news file" )
128- git .push ()
129- git .pull ()
129+ if not local :
130+ git .push ()
131+ git .pull ()
130132
131133
132134def main () -> None :
@@ -152,8 +154,8 @@ def main() -> None:
152154 except Exception as e :
153155 log_exception (logger , e )
154156 try :
155- news_file = generate_news_file (git , absolute_news_dir )
156- _commit_news_file (git , news_file )
157+ news_file = generate_news_file (git , git . get_corresponding_path ( pathlib . Path ( news_dir )) )
158+ _commit_news_file (git , news_file , args . local )
157159 except Exception as e2 :
158160 log_exception (logger , e2 )
159161 sys .exit (1 )
0 commit comments