From 59eb9ca0db2dfb583e1f61bf9cc4ebce7d1dbeba Mon Sep 17 00:00:00 2001 From: Anna Born Date: Fri, 8 Mar 2024 20:39:06 +0100 Subject: [PATCH 1/4] add option to disable the .git suffix --- lib/autoproj/git_server_configuration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/autoproj/git_server_configuration.rb b/lib/autoproj/git_server_configuration.rb index 4568b841..55b7d64d 100644 --- a/lib/autoproj/git_server_configuration.rb +++ b/lib/autoproj/git_server_configuration.rb @@ -73,7 +73,8 @@ def self.git_server_configuration(name, base_url, disabled_methods: [], config: Autoproj.config, fallback_to_http: nil, - lazy: false) + lazy: false, + add_suffix: true) disabled_methods = Array(disabled_methods) @@ -100,7 +101,8 @@ def self.git_server_configuration(name, base_url, end Autoproj.add_source_handler name.downcase do |url, private: false, **vcs_options| - url += ".git" if url !~ /\.git$/ + if add_suffix + url += ".git" if url !~ /\.git$/ url = "/#{url}" if url !~ /^\// unless GIT_SERVER_CONFIG_VARS.all? { |v| config.has_value_for?("#{name}#{v}") } From c2a7bdf64e122134c2c3ada475e3dd24a77ed28c Mon Sep 17 00:00:00 2001 From: Anna Born Date: Fri, 8 Mar 2024 20:48:15 +0100 Subject: [PATCH 2/4] fix previous broken commit --- lib/autoproj/git_server_configuration.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/autoproj/git_server_configuration.rb b/lib/autoproj/git_server_configuration.rb index 55b7d64d..3f1c467f 100644 --- a/lib/autoproj/git_server_configuration.rb +++ b/lib/autoproj/git_server_configuration.rb @@ -103,6 +103,7 @@ def self.git_server_configuration(name, base_url, Autoproj.add_source_handler name.downcase do |url, private: false, **vcs_options| if add_suffix url += ".git" if url !~ /\.git$/ + end url = "/#{url}" if url !~ /^\// unless GIT_SERVER_CONFIG_VARS.all? { |v| config.has_value_for?("#{name}#{v}") } From dde6f6b229dd5666bee02a5b5bb33c75dfe79a4a Mon Sep 17 00:00:00 2001 From: Anna Born Date: Fri, 8 Mar 2024 20:51:56 +0100 Subject: [PATCH 3/4] merged the nested conditions --- lib/autoproj/git_server_configuration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/autoproj/git_server_configuration.rb b/lib/autoproj/git_server_configuration.rb index 3f1c467f..b0b63844 100644 --- a/lib/autoproj/git_server_configuration.rb +++ b/lib/autoproj/git_server_configuration.rb @@ -101,8 +101,8 @@ def self.git_server_configuration(name, base_url, end Autoproj.add_source_handler name.downcase do |url, private: false, **vcs_options| - if add_suffix - url += ".git" if url !~ /\.git$/ + if add_suffix && url !~ /\.git$/ + url += ".git" end url = "/#{url}" if url !~ /^\// From 9d49c9663903d234f4a369ab6c4e442e71ffb1f4 Mon Sep 17 00:00:00 2001 From: Anna Born Date: Fri, 8 Mar 2024 20:55:45 +0100 Subject: [PATCH 4/4] write if statement as a if modifier --- lib/autoproj/git_server_configuration.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/autoproj/git_server_configuration.rb b/lib/autoproj/git_server_configuration.rb index b0b63844..69ae4cce 100644 --- a/lib/autoproj/git_server_configuration.rb +++ b/lib/autoproj/git_server_configuration.rb @@ -101,9 +101,7 @@ def self.git_server_configuration(name, base_url, end Autoproj.add_source_handler name.downcase do |url, private: false, **vcs_options| - if add_suffix && url !~ /\.git$/ - url += ".git" - end + url += ".git" if add_suffix && url !~ /\.git$/ url = "/#{url}" if url !~ /^\// unless GIT_SERVER_CONFIG_VARS.all? { |v| config.has_value_for?("#{name}#{v}") }