Skip to content

Instantly share code, notes, and snippets.

@veganstraightedge
Created November 4, 2021 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veganstraightedge/c31adcd1e3e6453e639814e38cfcc348 to your computer and use it in GitHub Desktop.
Save veganstraightedge/c31adcd1e3e6453e639814e38cfcc348 to your computer and use it in GitHub Desktop.
If you can't use Dependabot (or something like it) for some reasons, you can be a DependaHuman by running this script in two parts. First copy/paste line 11 to your Terminal. Then copy that output from the Terminal into the bottom of this script under that `__END__` and run the script.
# Command to run:
# bundle outdated --parseable
# OR:
# bundle outdated --strict --parseable
# OR:
# bundle outdated --strict --parseable --filter-patch;
# bundle outdated --strict --parseable --filter-minor;
# bundle outdated --strict --parseable --filter-major;
# OR as one line:
=begin
bundle outdated --strict --parseable --filter-patch; bundle outdated --strict --parseable --filter-minor; bundle outdated --strict --parseable --filter-major;
=end
one_big_command = []
DATA.each do |gem|
# skip blank lines
next if gem == "\n"
# skip commented out lines
next if gem.start_with? "#"
# parse pieces
name, versions = gem.split(" (")
newest = versions.split("newest ").last.split(", installed ").first
installed = versions.split("newest ").last.split(", installed ").last.split(")").first
# account for gems using private repos with spaces and SHAs in their versions
newest.gsub!(" ", "_")
installed.gsub!(" ", "_")
# for commands
message = "Version bump #{name} from #{installed} to #{newest}"
branch = "gem_version_bump__#{name}_from_#{installed}_to_#{newest}"
create_pr = "gh pr create --title '#{message}' --body '' --draft"
commands = [
# "say Starting #{name}.",
"git add .",
"git stash",
"git checkout master",
"git checkout -b #{branch}",
"bundle update #{name}",
"git add .",
"git commit -m '#{message}'",
"git push",
"#{create_pr}",
"git checkout master",
"git branch -D #{branch}",
# "say Finished #{name}."
]
command = commands.join(" && ")
# build it up
one_big_command << command
end
# print the one big command to run in Terminal
puts one_big_command.join " && "
# list of gems to update:
# Paste a list of gems Below the "__END__" from the 'bundle outdated --parseable' command at the top
# Comment out any you wanna skip for whatever reason
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment