@@ -93,12 +93,12 @@ def validate_news_files(git: GitWrapper, root_dir: str, news_dir: str) -> None:
93
93
validate_news_file (absolute_file_path )
94
94
95
95
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 :
97
97
"""Adds a news file if the branch corresponds to an dependency update.
98
98
99
99
Args:
100
100
git: Instance of GitWrapper.
101
- news_dir: Relative path to news directory.
101
+ news_dir: path to news directory.
102
102
"""
103
103
current_branch = str (git .get_current_branch ())
104
104
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:
114
114
)
115
115
logger .info (f"Generating a news file with content: { message } ..." )
116
116
return create_news_file (
117
- news_dir ,
117
+ str ( news_dir ) ,
118
118
message ,
119
119
configuration .get_value (ConfigurationVariable .DEPENDENCY_UPDATE_NEWS_TYPE ),
120
120
)
121
121
122
122
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 :
124
124
logger .info (f"Committing news file { str (news_file )} ..." )
125
- git .configure_for_github ()
125
+ if not local :
126
+ git .configure_for_github ()
126
127
git .add (str (news_file ))
127
128
git .commit ("📰 Automatic changes ⚙ Adding news file" )
128
- git .push ()
129
- git .pull ()
129
+ if not local :
130
+ git .push ()
131
+ git .pull ()
130
132
131
133
132
134
def main () -> None :
@@ -152,8 +154,8 @@ def main() -> None:
152
154
except Exception as e :
153
155
log_exception (logger , e )
154
156
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 )
157
159
except Exception as e2 :
158
160
log_exception (logger , e2 )
159
161
sys .exit (1 )
0 commit comments