From 2517c4b39bfa646f51f808253ac78cb404866b5b Mon Sep 17 00:00:00 2001 From: Davide Date: Fri, 11 Oct 2024 19:51:06 +0200 Subject: [PATCH] Revert CHANGELOG on cancel --- fastlane/Fastfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index efcf93b5..8ea174ab 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -14,6 +14,7 @@ # update_fastlane fastlane_require "dotenv" +fastlane_require "fileutils" Dotenv.load ".env.secret" setup_ci if ENV["CI"] @@ -27,10 +28,16 @@ lane :bump do |options| date_format: "short" ) path = "../#{logname}" - File.open(path, "w") { |file| + path_tmp = "#{path}.tmp" + File.open(path_tmp, "w") { |file| file.write(log) } - system("vim", path) or UI.user_error!("CHANGELOG editor cancelled") + if system("vim", path_tmp) + FileUtils.mv(path_tmp, path) + else + File.delete(path_tmp) + UI.user_error!("CHANGELOG editor cancelled") + end end version = options[:version] build = options[:build]