Skip to content

Commit

Permalink
[build] fix git code in rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jan 25, 2024
1 parent 319e4d7 commit ad4fb54
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -1030,18 +1030,14 @@ namespace :all do
Rake::Task['all:docs'].invoke
Rake::Task['all:version'].invoke('nightly')

puts "Staging nightly version updates"
@git.add(['java/version.bzl',
'rb/lib/selenium/webdriver/version.rb',
'rb/Gemfile.lock',
'rust/BUILD.bazel',
'rust/Cargo.Bazel.lock',
'rust/Cargo.lock',
'rust/Cargo.toml'],
all: true)
puts "Committing nightly version updates"
@git.commit('update versions to nightly')
puts "Pushing changes to upstream repository"
commit!('update versions to nightly', ['java/version.bzl',
'rb/lib/selenium/webdriver/version.rb',
'rb/Gemfile.lock',
'rust/BUILD.bazel',
'rust/Cargo.Bazel.lock',
'rust/Cargo.lock',
'rust/Cargo.toml'])

print 'Do you want to push the committed changes? (Y/n): '
response = STDIN.gets.chomp.downcase
Expand Down Expand Up @@ -1175,15 +1171,12 @@ def update_gh_pages
end
end

puts "Staging changes for commit"
@git.add('docs/api', all: true)

print 'Do you want to commit the changes? (Y/n): '
response = STDIN.gets.chomp.downcase
return restore_git(origin_reference) unless response == 'y' || response == 'yes'

puts "Committing changes"
@git.commit('updating all API docs')
commit!('updating all API docs', 'docs/api/')

puts "Pushing changes to upstream repository"
@git.push
Expand Down Expand Up @@ -1246,3 +1239,13 @@ def update_changelog(version, language, path, changelog, header)
file.truncate(file.pos)
end
end

def commit!(message, files = [], all: false)
files.each do |file|
puts "adding: #{file}"
@git.add(file)
end
all ? @git.commit_all(message) : @git.commit(message)
rescue Git::FailedError => ex
puts ex.message
end

0 comments on commit ad4fb54

Please sign in to comment.