Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _None_

### Internal Changes

_None_
- Run the `GitHelper` git-lfs specs against a sandboxed `GIT_CONFIG_GLOBAL` so they no longer remove the `[filter "lfs"]` section from the developer's global git config. [#762]

## 14.11.1

Expand Down
27 changes: 22 additions & 5 deletions spec/git_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'tempfile'
require 'tmpdir'
require_relative 'spec_helper'

Expand Down Expand Up @@ -57,15 +58,19 @@

it 'can detect a repository with Git-lfs enabled' do
init_git_repo
`git lfs install`
expect(described_class.has_git_lfs?).to be true
with_sandboxed_global_git_config do
`git lfs install`
expect(described_class.has_git_lfs?).to be true
end
end

it 'can detect a repository without Git-lfs enabled' do
init_git_repo
`git lfs uninstall &>/dev/null`
expect(described_class.is_git_repo?).to be true
expect(described_class.has_git_lfs?).to be false
with_sandboxed_global_git_config do
`git lfs uninstall &>/dev/null`
expect(described_class.is_git_repo?).to be true
expect(described_class.has_git_lfs?).to be false
end
end

describe 'commit(message:, files:)' do
Expand Down Expand Up @@ -262,6 +267,18 @@ def init_git_repo
`git init --initial-branch main || git init`
end

# `git lfs install` and `git lfs uninstall` write to the global scope unless told
# otherwise, so without this the examples edit the developer's real `~/.gitconfig`.
def with_sandboxed_global_git_config
Tempfile.create('gitconfig') do |file|
original = ENV['GIT_CONFIG_GLOBAL']
ENV['GIT_CONFIG_GLOBAL'] = file.path
yield
ensure
ENV['GIT_CONFIG_GLOBAL'] = original
end
end

def add_file_and_commit(file:, message:)
`touch #{file}`
`git add .`
Expand Down