Skip to content

Commit

Permalink
Merge pull request #122 from flavorjones/119-improve-patching
Browse files Browse the repository at this point in the history
fix: handle patching in dirs that resemble an actual git dir
  • Loading branch information
flavorjones authored Dec 24, 2022
2 parents e3553fc + b36e409 commit 9821cbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## mini_portile changelog

### next / unreleased

#### Fixed

- Support applying patches via `git apply` even when the working directory resembles a git directory. [#119] (Thanks, @h0tw1r3!)


### 2.8.0 / 2022-02-20

#### Added
Expand Down
6 changes: 3 additions & 3 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def apply_patch(patch_file)
when which('git')
lambda { |file|
message "Running git apply with #{file}... "
# By --work-tree=. git-apply uses the current directory as
# the project root and will not search upwards for .git.
execute('patch', ["git", "--git-dir=.", "--work-tree=.", "apply", "--whitespace=warn", file], :initial_message => false)
Dir.mktmpdir do |tmp_git_dir|
execute('patch', ["git", "--git-dir=#{tmp_git_dir}", "--work-tree=.", "apply", "--whitespace=warn", file], :initial_message => false)
end
}
when which('patch')
lambda { |file|
Expand Down

0 comments on commit 9821cbb

Please sign in to comment.