Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Go tmp directories #4346

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 3 additions & 1 deletion go_modules/lib/dependabot/go_modules/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ def updated_dependency_files

vendor_updater.updated_vendor_cache_files(base_directory: directory).
each do |file|
updated_files << file
updated_files << file
end
end

raise "No files changed!" if updated_files.none?

updated_files
ensure
FileUtils.remove_entry(@repo_contents_path, force=true) if File.exists?(@repo_contents_path)
end

private
Expand Down
14 changes: 8 additions & 6 deletions go_modules/spec/dependabot/go_modules/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ module declares its path as: go.etcd.io/bbolt
)
end

subject(:updated_files) { updater.updated_dependency_files }

it "includes an updated go.mod" do
expect(updated_files.find { |f| f.name == "go.mod" }).to_not be_nil
end
Expand Down Expand Up @@ -226,20 +228,20 @@ module declares its path as: go.etcd.io/bbolt
}]
end

subject(:updated_files) { updater.updated_dependency_files }

it "updates the go.mod" do
expect(go_mod_body).to include("github.com/pkg/errors v0.8.0")

updater.updated_dependency_files

go_mod_file = updater.updated_dependency_files.find do |file|
go_mod_file = updated_files.find do |file|
file.name == "go.mod"
end

expect(go_mod_file.content).to include "github.com/pkg/errors v0.9.1"
end

it "includes the vendored files" do
expect(updater.updated_dependency_files.map(&:name)).to match_array(
expect(updated_files.map(&:name)).to match_array(
%w(
go.mod
go.sum
Expand Down Expand Up @@ -316,7 +318,7 @@ module declares its path as: go.etcd.io/bbolt
end

it "vendors in the right directory" do
expect(updater.updated_dependency_files.map(&:name)).to match_array(
expect(updated_files.map(&:name)).to match_array(
%w(
go.mod
go.sum
Expand All @@ -330,7 +332,7 @@ module declares its path as: go.etcd.io/bbolt
)
)

updater.updated_dependency_files.map(&:directory).each do |dir|
updated_files.map(&:directory).each do |dir|
expect(dir).to eq("/nested")
end
end
Expand Down