Skip to content

Commit

Permalink
Resolves Issue #150 - Rename Template Crashes (#151)
Browse files Browse the repository at this point in the history
When rename_template.rb was run with a remote repository
that did not end in .git, it would previously crash.

These changes modify the regex to return the repo correctly
in either case as well as providing a nil value if no repo
is found without crashing.

Co-authored-by: Amy Nadboralski <amy@powder.rocks>
  • Loading branch information
powder and amethystpixie authored Aug 15, 2023
1 parent b69faa8 commit 7fe19a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rename_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ def read_git_data
return {} unless git("remote", "-v").match?(/^origin/)

origin_url = git("remote", "get-url", "origin").chomp
origin_repo_path = origin_url[%r{[:/]([^/]+/[^/]+)(?:\.git)$}, 1]
origin_repo_path = origin_url[%r{[:/]([^/]+/[^/]+?)(?:\.git)?$}, 1]

{
origin_repo_name: origin_repo_path.split("/").last,
origin_repo_name: origin_repo_path&.split("/")&.last,
origin_repo_path: origin_repo_path,
user_email: git("config", "user.email").chomp,
user_name: git("config", "user.name").chomp
Expand Down

0 comments on commit 7fe19a7

Please sign in to comment.