From a75e0f5165d6b785810b36c5df7a2e59d64838dd Mon Sep 17 00:00:00 2001 From: Robert Peacock Date: Fri, 12 Jan 2024 12:03:35 +0000 Subject: [PATCH 1/5] typos --- lib/command.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/command.rb b/lib/command.rb index 8c50aab..3dbff2f 100644 --- a/lib/command.rb +++ b/lib/command.rb @@ -11,8 +11,8 @@ class Command def initialize(config) @config = config comment = config.payload['comment']['body'].strip.downcase - error_msg = "Comment must be start with #{COMMAND_PREFIX}" - puts "::error title=Arguement Error::#{error_msg}" + error_msg = "Comment must start with #{COMMAND_PREFIX}" + puts "::error title=Argument Error::#{error_msg}" raise ArgumentError, error_msg unless comment.start_with?(COMMAND_PREFIX) cmd = comment.delete_prefix(COMMAND_PREFIX) From d3a64637ccc4102f08ede72323f8cb496656d697 Mon Sep 17 00:00:00 2001 From: Robert Peacock Date: Fri, 12 Jan 2024 14:22:56 +0000 Subject: [PATCH 2/5] adapt regex so it will work for other version files --- lib/utils/bump.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/utils/bump.rb b/lib/utils/bump.rb index d1b104c..153c9cc 100644 --- a/lib/utils/bump.rb +++ b/lib/utils/bump.rb @@ -4,9 +4,10 @@ require_relative 'commit' class Bump - SEMVER_VERSION = - /["'](0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']/ # rubocop:disable Layout/LineLength - GEMSPEC_VERSION = Regexp.new(/\.version\s*=\s*/.to_s + SEMVER_VERSION.to_s).freeze + SEMVER = /["']*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']*/ + SEPARATOR = /\s*[:=]\s*/ + VERSION_KEY = /version/ + VERSION_SETTING = Regexp.new(VERSION_KEY.source + SEPARATOR.source + SEMVER.source, Regexp::IGNORECASE).freeze def initialize(config, level) @config = config @@ -56,8 +57,8 @@ def assign_pr_attributes!(pr_number) end def fetch_version(content) - version = content.content.match(GEMSPEC_VERSION) || content.content.match(SEMVER_VERSION) - Semantic::Version.new(version[0].split('=').last.gsub(/\s/, '').gsub(/'|"/, '')) + version = content.content.match(VERSION_SETTING) + Semantic::Version.new(version[0].split(SEPARATOR).last.gsub(/\s/, '').gsub(/'|"/, '')) end def bump_version(version, level) From 76672928ee3d89dc2ab7520caa6b6f66250284e3 Mon Sep 17 00:00:00 2001 From: Robert Peacock Date: Fri, 12 Jan 2024 14:30:13 +0000 Subject: [PATCH 3/5] update docs to include other langs --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 88c3150..178c648 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ “Dobby is free.” -A Github action which provides chat-ops functionality. You can comment on Pull request to perform various operations. -Currently it supports bumping version for a gem. +A Github action which provides chat-ops functionality. You can comment on a pull request to perform various operations. +Currently it supports bumping version files in Ruby, Python and Javascript. The version file (see below) must specify the version +as a key-value pair separated by either ":" or "=", e.g. `VERSION: '1.2.3'` or `version = 1.2.3` ## Bump version @@ -14,8 +15,8 @@ Dobby requires a Github App to be installed either on an individual repository o - Set GitHub App name. - Set Homepage URL to your github repository. - Uncheck Active under Webhook. You do not need to enter a Webhook URL. - - Under Repository permissions: Contents select Access: Read & write. - - Under Repository permissions: Pull requests select Access: Read & write. + - Under Permissions & Events > Repository permissions > Contents select Access: Read & write. + - Under Permissions & Events > Repository permissions > Pull requests select Access: Read & write. 2. Create a Private key from the App settings page and store it securely. From ce1d4e6f31f070690484f4a58e06d617cd4697c5 Mon Sep 17 00:00:00 2001 From: Robert Peacock Date: Fri, 12 Jan 2024 14:39:52 +0000 Subject: [PATCH 4/5] reinstate line length disable --- lib/utils/bump.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/bump.rb b/lib/utils/bump.rb index 153c9cc..9f57a9d 100644 --- a/lib/utils/bump.rb +++ b/lib/utils/bump.rb @@ -4,7 +4,7 @@ require_relative 'commit' class Bump - SEMVER = /["']*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']*/ + SEMVER = /["']*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']*/ # rubocop:disable Layout/LineLength SEPARATOR = /\s*[:=]\s*/ VERSION_KEY = /version/ VERSION_SETTING = Regexp.new(VERSION_KEY.source + SEPARATOR.source + SEMVER.source, Regexp::IGNORECASE).freeze From 41201961b02aede4dd62174a0e78b48cff59f629 Mon Sep 17 00:00:00 2001 From: Robert Peacock Date: Fri, 12 Jan 2024 15:00:04 +0000 Subject: [PATCH 5/5] handle edge case where required_ruby_version appears first in gemspec --- lib/utils/bump.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/bump.rb b/lib/utils/bump.rb index 9f57a9d..08b1e0e 100644 --- a/lib/utils/bump.rb +++ b/lib/utils/bump.rb @@ -6,7 +6,7 @@ class Bump SEMVER = /["']*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']*/ # rubocop:disable Layout/LineLength SEPARATOR = /\s*[:=]\s*/ - VERSION_KEY = /version/ + VERSION_KEY = /(^|\.|\s)version/ VERSION_SETTING = Regexp.new(VERSION_KEY.source + SEPARATOR.source + SEMVER.source, Regexp::IGNORECASE).freeze def initialize(config, level)