From 8bbb79ba5395fc29579fbaf5f58c1e47e7e5c8d0 Mon Sep 17 00:00:00 2001 From: sanemat Date: Mon, 23 Dec 2013 19:46:23 +0900 Subject: [PATCH 1/2] Glob repository identifier --- spec/tachikoma/application_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/tachikoma/application_spec.rb b/spec/tachikoma/application_spec.rb index 550e12e..26ddaf6 100644 --- a/spec/tachikoma/application_spec.rb +++ b/spec/tachikoma/application_spec.rb @@ -76,4 +76,22 @@ end end end + + describe '#repository_identity' do + subject { described_class.new } + let(:identity) { 'example1/example2' } + + context 'https with .git' do + let(:url) { 'https://github.com/example1/example2.git' } + it { expect(subject.repository_identity(url)).to eq identity } + end + context 'https without .git' do + let(:url) { 'https://github.com/example1/example2' } + it { expect(subject.repository_identity(url)).to eq identity } + end + context 'https with trail slash' do + let(:url) { 'https://github.com/example1/example2/' } + it { pending; expect(subject.repository_identity(url)).to eq identity } + end + end end From c98c592af9e3a12e6f27d273dfac22f752bf297b Mon Sep 17 00:00:00 2001 From: sanemat Date: Mon, 23 Dec 2013 19:53:28 +0900 Subject: [PATCH 2/2] Fix trailing slash --- lib/tachikoma/application.rb | 2 +- spec/tachikoma/application_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tachikoma/application.rb b/lib/tachikoma/application.rb index b29cc7c..1076cbc 100644 --- a/lib/tachikoma/application.rb +++ b/lib/tachikoma/application.rb @@ -141,7 +141,7 @@ def target_repository_user(type, fetch_url, github_account) end def repository_identity(url) - %r!((?:[^/]*?)/(?:[^/]*?))(?:\.git)?$!.match(url)[1] + %r!((?:[^/]*?)/(?:[^/]*?))(?:\.git|/)?$!.match(url)[1] end def bundler_parallel_option(bundler_version, parallel_number) diff --git a/spec/tachikoma/application_spec.rb b/spec/tachikoma/application_spec.rb index 26ddaf6..5e89cea 100644 --- a/spec/tachikoma/application_spec.rb +++ b/spec/tachikoma/application_spec.rb @@ -91,7 +91,7 @@ end context 'https with trail slash' do let(:url) { 'https://github.com/example1/example2/' } - it { pending; expect(subject.repository_identity(url)).to eq identity } + it { expect(subject.repository_identity(url)).to eq identity } end end end