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

fetch files directly from git #918

Merged
merged 1 commit into from
May 2, 2016
Merged

fetch files directly from git #918

merged 1 commit into from
May 2, 2016

Conversation

grosser
Copy link
Contributor

@grosser grosser commented May 2, 2016

remove github dependency and make file fetching faster

 Benchmark.realtime { p.repository.send :file_content, "59aa8ab37f013f4b8fe7d87e30edbc808175b51b", 'Gemfile' }
=> 0.03225039999233559

@zendesk/samson

Risks

  • Low: slow operations when repo is not cached .. which should not happen since we resolve the sha before hitting this codepath anyway

@irwaters
Copy link
Contributor

irwaters commented May 2, 2016

👍

@grosser grosser merged commit d4a6db9 into master May 2, 2016
@grosser grosser deleted the grosser/direct branch May 2, 2016 16:10
@@ -114,8 +107,22 @@ def file_changed?(sha1, sha2, file)
executor.execute!("cd #{pwd}", "git diff --quiet --name-only #{sha1}..#{sha2} #{file}")
end

def file_content(sha, file)
raise ArgumentError, "Need a sha, but #{sha} (#{sha.size}) given" unless sha.size == 40
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the Build model has a validation that the git_sha attribute is a valid SHA1. Might want to extract out the logic for checking that something is a valid SHA and use that, rather than checking length here, and using a regex there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, taken care of in next PR

On Mon, May 2, 2016 at 9:17 AM, Jon Moter notifications@github.com wrote:

In app/models/git_repository.rb
#918 (comment):

@@ -114,8 +107,22 @@ def file_changed?(sha1, sha2, file)
executor.execute!("cd #{pwd}", "git diff --quiet --name-only #{sha1}..#{sha2} #{file}")
end

  • def file_content(sha, file)
  • raise ArgumentError, "Need a sha, but #{sha} (#{sha.size}) given" unless sha.size == 40

FYI, the Build model has a validation that the git_sha attribute is a
valid SHA1. Might want to extract out the logic for checking that something
is a valid SHA and use that, rather than checking length here, and using a
regex there.


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
https://github.com/zendesk/samson/pull/918/files/a1302c1aa7a6e1c2937dc80b57a57eec9b3309cc#r61761260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants