-
Notifications
You must be signed in to change notification settings - Fork 938
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
Pushing changes in progress for git-lfs support adding to entire ecosystem. #9766
Open
GarryHurleyJr
wants to merge
22
commits into
main
Choose a base branch
from
GarryHurleyJr/6039-add-support-in-dependabot-core-for-lfs-as-an-option-for-repositories
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+77
−21
Open
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
85ad379
Pushing changes in progress
GarryHurleyJr 528b2ad
Merge branch 'main' into GarryHurleyJr/6039-add-support-in-dependabot…
GarryHurleyJr b7858c5
Corrected the approach for determining the command string.
GarryHurleyJr 416f73c
cleanup of common files
GarryHurleyJr 1be323c
cleanup of common files
GarryHurleyJr fed7b21
Git class updates
GarryHurleyJr 859e451
Pushing changes in progress
GarryHurleyJr b58fb65
Corrected the approach for determining the command string.
GarryHurleyJr 00b1f37
cleanup of common files
GarryHurleyJr aa9e64e
cleanup of common files
GarryHurleyJr e610181
Git class updates
GarryHurleyJr bd0ba9c
Merge branch 'GarryHurleyJr/6039-add-support-in-dependabot-core-for-l…
GarryHurleyJr 512226c
sorbet fixes
GarryHurleyJr 3880844
sorbet fixes
GarryHurleyJr 7278432
sorbet fixes
GarryHurleyJr 6ac6646
sorbet fixes
GarryHurleyJr 32cf333
lint fixes
GarryHurleyJr 1fd1283
lint fixes
GarryHurleyJr 037657b
lint fixes
GarryHurleyJr f079add
lint fixes
GarryHurleyJr 5f555ef
lint fixes
GarryHurleyJr b5ec97b
lint fixes
GarryHurleyJr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -861,19 +861,35 @@ def decode_binary_string(str) | |
|
||
sig { params(path: String).returns(T::Array[String]) } | ||
def find_submodules(path) | ||
SharedHelpers.run_shell_command( | ||
<<~CMD | ||
git -C #{path} ls-files --stage | ||
CMD | ||
).split("\n").filter_map do |line| | ||
lfsEnabled = true | ||
commandString = getCommandString(path,lfsEnabled) | ||
/debugger | ||
p commandString/ | ||
SharedHelpers.run_shell_command(commandString | ||
).split("\n").filter_map do |line| | ||
info = line.split | ||
|
||
type = info.first | ||
path = T.must(info.last) | ||
|
||
debugger | ||
next path if type == DependencyFile::Mode::SUBMODULE | ||
end | ||
end | ||
|
||
def getCommandString(path,lfsEnabled) | ||
#the HEREDOC command will see any stray spaces. | ||
return "git -C #{path} ls-files --stage" unless lfsEnabled | ||
Dependabot.logger.warn("LFS is enabled in this repo. Please use an LFS enabled client") | ||
commandString = "CWD=\"#{__dir__}\";cd #{path};git-lfs ls-files --stage;cd $CWD" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggested something a little simpler above, but just adding a couple notes:
|
||
# return "\"CWD=`pwd`;cd #{path};#git-lfs ls-files --stage;cd $CWD\"" | ||
return commandString | ||
end | ||
|
||
def getGitCommand(lfsEnabled) | ||
return "git" unless !!lfsEnabled | ||
Dependabot.logger.warn("LFS is enabled in this repo. Please use an LFS enabled client") | ||
return "git-lfs" | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,6 +302,42 @@ def fetch_files | |
before do | ||
allow(file_fetcher_instance).to receive(:commit).and_return("sha") | ||
end | ||
#start of lfs testing | ||
context "with data stored in git-lfs" do | ||
# debugger | ||
# let(:source) do | ||
# Dependabot::Source.new( | ||
# provider: "github", | ||
# repo: repo, | ||
# directory: directory | ||
# ) | ||
# end | ||
let(:url) { "https://api.github.com/repos/dependabot-fixtures/dependabot-yarn-lfs-fixture/contents/" } | ||
let(:repo) { "dependabot-fixtures/dependabot-yarn-lfs-fixture" } | ||
let(:repo_contents_path) { Dir.mktmpdir } | ||
after { FileUtils.rm_rf(repo_contents_path) } | ||
|
||
let(:file_fetcher_instance) do | ||
described_class.new(source: source, credentials: credentials, repo_contents_path: repo_contents_path) | ||
end | ||
|
||
it "pulls files from lfs after cloning" do | ||
# Calling #files triggers the clone | ||
expect(file_fetcher_instance.files.map(&:name)).to contain_exactly("package.json", "yarn.lock", ".yarnrc.yml") | ||
expect( | ||
File.read( | ||
File.join(repo_contents_path, ".yarn", "releases", "yarn-3.2.4.cjs") | ||
) | ||
).to start_with("#!/usr/bin/env node") | ||
|
||
# LFS files not needed by dependabot are not pulled | ||
expect( | ||
File.read( | ||
File.join(repo_contents_path, ".pnp.cjs") | ||
) | ||
).to start_with("version https://git-lfs.github.com/spec/v1") | ||
end | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have unit tests covering these new scenarios? |
||
context "with a GitHub source" do | ||
its(:length) { is_expected.to eq(1) } | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be simplified a bit without the helper methods and by using
Dir.chdir