captive-release 0.16.1 → 0.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c2523bc6af5687a507068ff5e95f50bf46e686ac639af47888c540ef5d9f17c
4
- data.tar.gz: b61f763485c298ff7eca5254367fb7da0cf14cd74eba6d78b762fa3a247e3b3a
3
+ metadata.gz: ee8c3f00a3a506e332e7db04b0566dacb21c9865b38ac76ca08ef591049ec540
4
+ data.tar.gz: 240e9128f724f932cdb96b05586abd09e87b1776b5ef2fd27a9e4232c4f492b3
5
5
  SHA512:
6
- metadata.gz: cf83f1cac7aee5c449d2288920913781273f6016d896887091c27e1ab2c5ff83a9c838c891efb9d363d4d7e2386aacf73bdc4edaff55e1931afb26339ca7b2b2
7
- data.tar.gz: f3e2c84758f1860a04bdd696ea8c7a792769b85b4745e01c36aa32b388cafa52b1b2b9cfee577b3050b15e09991f179f1a69b44347f412d09f503cd9eb2ee0ac
6
+ metadata.gz: c7f8edef4ccb729148debbfa08eb87709b0091c04cc814185878f5e882db1036b08164cbdbf64b5bc99fe6ab318a3272d3ae2e280bd9a62a49adda4caa8a2d17
7
+ data.tar.gz: bdc89f8df5c2ccac587bac93ca0cbb372597e7b114d29735e4cd93928f38a3f96a2386d4b2f298551b682d5631d5249ceaed5dfb263e751b4e7d3ac3775ea344
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CaptiveRelease
4
+ # Alerte quand la release part d'une autre branche que la principale : le tag désignerait
5
+ # un commit que la branche principale ne contient pas.
6
+ #
7
+ # Cette unité change quand la politique de branche change, ReleasePreconditions quand les
8
+ # conditions bloquantes changent.
9
+ class DefaultBranchGuard
10
+ def initialize(terminal:)
11
+ @terminal = terminal
12
+ end
13
+
14
+ def verifier!
15
+ courante = GitCommands.current_branch
16
+ principale = GitCommands.default_branch
17
+ return if courante == principale
18
+
19
+ @terminal.say Messages.t(:not_on_default_branch, branch: courante, default: principale)
20
+ exit 1 unless Messages.yes?(@terminal.ask(Messages.t(:continue_anyway)))
21
+ end
22
+ end
23
+ end
@@ -21,6 +21,13 @@ module CaptiveRelease
21
21
  Shell.capture_lines("git log --pretty=%s #{Shell.escape(tag)}..HEAD")
22
22
  end
23
23
 
24
+ def self.repository? = Shell.run?("git rev-parse --is-inside-work-tree >/dev/null 2>&1")
25
+
26
+ # La branche par défaut du remote ; sans origin/HEAD connu, main par convention.
27
+ def self.default_branch
28
+ Shell.capture("git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null")[%r{\Aorigin/(.+)}, 1] || "main"
29
+ end
30
+
24
31
  def self.current_branch
25
32
  branche = Shell.capture("git rev-parse --abbrev-ref HEAD 2>/dev/null")
26
33
  branche.empty? ? "main" : branche
@@ -79,6 +79,8 @@ en:
79
79
  workflow_not_found: |-
80
80
  Workflow %{workflow} not found on %{repo}.
81
81
  Add .github/workflows/%{workflow} to the default branch, or fix build_workflow in the configuration.
82
+ not_a_git_repository: Not a git repository. Run captive-release from inside a repository.
83
+ not_on_default_branch: "⚠️ You are on branch %{branch}, not on the default branch %{default}."
82
84
  dirty_tree: The working tree is not clean.
83
85
  dirty_tree_hint: Commit or stash your changes before releasing.
84
86
  current_version: 'Current version: %{version}'
@@ -79,6 +79,8 @@ fr:
79
79
  workflow_not_found: |-
80
80
  Workflow %{workflow} introuvable sur %{repo}.
81
81
  Ajoutez .github/workflows/%{workflow} sur la branche par défaut, ou corrigez build_workflow dans la configuration.
82
+ not_a_git_repository: Pas de dépôt git ici. Lancez captive-release depuis un dépôt.
83
+ not_on_default_branch: "⚠️ Vous êtes sur la branche %{branch}, pas sur la branche principale %{default}."
82
84
  dirty_tree: L'arbre de travail n'est pas propre.
83
85
  dirty_tree_hint: Commitez ou remisez vos modifications avant de releaser.
84
86
  current_version: 'Version actuelle : %{version}'
@@ -13,14 +13,8 @@ module CaptiveRelease
13
13
  end
14
14
 
15
15
  def run(bump_arg, confirmation:)
16
- ReleasePreconditions.new(terminal: @terminal).verifier!
17
- courante = @config.current_version
18
- suggestion = ReleaseOverview.new(terminal: @terminal).call(courante)
19
-
20
- prochaine = VersionChoice.new(terminal: @terminal).call(courante, bump_arg)
21
- PrereleaseGuard.new(terminal: @terminal).verifier!(prochaine, @config.version_files)
22
- ReleaseConfirmation.new(terminal: @terminal).verifier!(suggestion, courante, prochaine) if confirmation
23
-
16
+ prochaine = ReleaseVersionDecision.new(terminal: @terminal, version_files: @config.version_files)
17
+ .call(@config.current_version, bump_arg, confirmation: confirmation)
24
18
  VersionFilesWriting.new(terminal: @terminal).call(prochaine, @config.version_files)
25
19
  GitRelease.new(terminal: @terminal, token_provider: @token_provider).call(prochaine, chemins_a_commiter)
26
20
  publication.call(prochaine)
@@ -14,11 +14,21 @@ module CaptiveRelease
14
14
  end
15
15
 
16
16
  def verifier!
17
+ verifier_depot!
17
18
  return unless GitCommands.dirty?
18
19
 
19
20
  @terminal.say @terminal.error(Messages.t(:dirty_tree))
20
21
  @terminal.say "#{Messages.t(:dirty_tree_hint)}\n"
21
22
  exit 1
22
23
  end
24
+
25
+ private
26
+
27
+ def verifier_depot!
28
+ return if GitCommands.repository?
29
+
30
+ @terminal.say @terminal.error(Messages.t(:not_a_git_repository))
31
+ exit 1
32
+ end
23
33
  end
24
34
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CaptiveRelease
4
+ # Décider vers quelle version on part : préconditions, choix, garde-fous, confirmation.
5
+ #
6
+ # Cette unité change quand la manière de choisir ou de valider la version change,
7
+ # ReleaseCommand quand les étapes qui appliquent cette version changent.
8
+ class ReleaseVersionDecision
9
+ def initialize(terminal:, version_files:)
10
+ @terminal = terminal
11
+ @version_files = version_files
12
+ end
13
+
14
+ def call(courante, bump_arg, confirmation:)
15
+ ReleasePreconditions.new(terminal: @terminal).verifier!
16
+ DefaultBranchGuard.new(terminal: @terminal).verifier! if confirmation
17
+ suggestion = ReleaseOverview.new(terminal: @terminal).call(courante)
18
+ prochaine = VersionChoice.new(terminal: @terminal).call(courante, bump_arg)
19
+ PrereleaseGuard.new(terminal: @terminal).verifier!(prochaine, @version_files)
20
+ ReleaseConfirmation.new(terminal: @terminal).verifier!(suggestion, courante, prochaine) if confirmation
21
+ prochaine
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CaptiveRelease
4
- VERSION = "0.16.1"
4
+ VERSION = "0.16.4"
5
5
  end
@@ -24,6 +24,7 @@ require_relative "captive_release/bump_suggestion"
24
24
  require_relative "captive_release/version_severity"
25
25
  require_relative "captive_release/bump_safety_net"
26
26
  require_relative "captive_release/prerelease_guard"
27
+ require_relative "captive_release/default_branch_guard"
27
28
  require_relative "captive_release/github_repo"
28
29
  require_relative "captive_release/github_http"
29
30
  require_relative "captive_release/github_api"
@@ -56,6 +57,7 @@ require_relative "captive_release/version_files_writing"
56
57
  require_relative "captive_release/release_preconditions"
57
58
  require_relative "captive_release/release_overview"
58
59
  require_relative "captive_release/release_confirmation"
60
+ require_relative "captive_release/release_version_decision"
59
61
  require_relative "captive_release/release_command"
60
62
  require_relative "captive_release/update_check"
61
63
  require_relative "captive_release/help"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: captive-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Captive Studio
@@ -35,6 +35,7 @@ files:
35
35
  - lib/captive_release/config_file.rb
36
36
  - lib/captive_release/config_loader.rb
37
37
  - lib/captive_release/config_writer.rb
38
+ - lib/captive_release/default_branch_guard.rb
38
39
  - lib/captive_release/direct_commits.rb
39
40
  - lib/captive_release/exclusion_input.rb
40
41
  - lib/captive_release/framework_detector.rb
@@ -69,6 +70,7 @@ files:
69
70
  - lib/captive_release/release_preconditions.rb
70
71
  - lib/captive_release/release_publication.rb
71
72
  - lib/captive_release/release_pull_request.rb
73
+ - lib/captive_release/release_version_decision.rb
72
74
  - lib/captive_release/repo_files.rb
73
75
  - lib/captive_release/ruby_gems_version.rb
74
76
  - lib/captive_release/semver.rb