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
Sets depth=1 to Git clone/fetch #622
Sets depth=1 to Git clone/fetch #622
Conversation
3d7b776
to
fa59eee
Compare
Will golang version resolution still work correctly? |
It might be correct, since the 'get_golang_version' function does 'fetch' operation itself. |
Ah, I didn't realize we pass |
Another potential problem is that the |
I'm thinking we could either: |
+1 for the first option |
cachito/workers/scm.py
Outdated
# Don't allow git to prompt for a username if we don't have access | ||
env={"GIT_TERMINAL_PROMPT": "0"}, | ||
) | ||
|
||
repo.remote().fetch(refspec=self.ref, depth=1) |
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.
Why do we need to have this line twice?
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.
Because the shallow clone always defaults to the lastest master commit, so we need to fetch the commit we're actually building.
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.
Aaah, I just forgot there are some lines between 170 and 194. My bad!
I started writing approach And if we go with Wdyt, @serg-cymbaluk @ejegrova @akhmanova? |
It is not hackish, since the purpose of that flag is to keep the git history. And if it is not needed, we can apply The second one sounds more like a workaround. |
Well, the purpose of the flag is to keep the whole git directory, although it seems the users are more interested in the refs in there. I still feel like it is less clear to see why But I see your point, if we interpret the flag as Maybe the feeling of hackish derived more from all the code layers I hade to "pierce" to pass a new argument... argh :D |
@brunoapimentel I am fine with the first approach too. I would not create another flag for this purpose, just renaming will be fine. Let's just update docs and say that without this flag only the last commit will be cloned. |
162990c
to
72bd76b
Compare
cachito/workers/scm.py
Outdated
@@ -143,7 +143,7 @@ def _create_archive(self, from_dir): | |||
os.unlink(self.sources_dir.archive_path) | |||
raise | |||
|
|||
def clone_and_archive(self, gitsubmodule=False): | |||
def clone_and_archive(self, gitsubmodule=False, include_git_dir=False): |
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.
Can we add a line about include_git_dir
param?
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.
You mean in the docstring? Sure, I missed that one.
cachito/workers/scm.py
Outdated
) | ||
repo = git.repo.Repo.clone_from(self.url, clone_path, **kwargs) | ||
|
||
if include_git_dir: |
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.
And what if we need a special commit and it's not the last one (and include_git_dir
is set to False)?
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.
If include_git_dir
is set to False
, a deep clone will be made, which means all commits will already be there. This is the current behavior, by the way.
tests/test_workers/test_scm.py
Outdated
@@ -89,6 +94,9 @@ def test_clone_and_archive( | |||
mock_ugs.assert_called_once_with(mock_clone.return_value) | |||
else: | |||
mock_ugs.assert_not_called() | |||
# |
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.
should it be empty?
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.
It should not. Holiday mood was impeding my brain. :D
72bd76b
to
3603ce3
Compare
3603ce3
to
898d847
Compare
This is to avoid exhausting the resources while cloning very large repos (such as github.com/openshift/origin, which consumes ~3GB memory). In case the "include-git-dir" flag is set, a deep clone will still be used. Signed-off-by: Bruno Pimentel <bpimente@redhat.com>
898d847
to
b49a041
Compare
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.
LGTM
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.
LGTM
This is to avoid exhausting the resources while cloning very large repos, such as github.com/openshift/origin, which is consuming ~3GB memory during the cloning process.
In order to maintain compatibility, this behavior will only be applied if there is no need to keep the Git repository in the resulting tarball (i.e.
include-git-dir
flag is absent).Maintainers will complete the following section