Skip to content

feat: support shallow git clones #660

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AnsahMohammad
Copy link
Contributor

Support the git shallow clones using --depth=1 flag.

This PR fixes #503

@AnsahMohammad
Copy link
Contributor Author

@ahal Can you take a look at this change?

Copy link
Collaborator

@ahal ahal left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

This looks like a good start, but the git_checkout function is internal to run-task, so there's no way for a user to request a shallow clone here. You'll need to trace backwards, forwarding the argument all the way until the main function, where you'll need to create a new command line argument for this.

It would also be much appreciated if you could update a test to cover this new flag somewhere in test/test_scripts_run_task.py :)

@AnsahMohammad
Copy link
Contributor Author

This looks like a good start, but the git_checkout function is internal to run-task, so there's no way for a user to request a shallow clone here. You'll need to trace backwards, forwarding the argument all the way until the main function, where you'll need to create a new command line argument for this.

It would also be much appreciated if you could update a test to cover this new flag somewhere in test/test_scripts_run_task.py :)

Oh yeah, good point—I didn’t think about that.
Sure i'll work on that !

@AnsahMohammad AnsahMohammad changed the title feat: support git shallow clones feat: support shallow git clones Mar 6, 2025
@AnsahMohammad AnsahMohammad requested a review from ahal March 6, 2025 11:14
Copy link
Collaborator

@ahal ahal left a comment

Choose a reason for hiding this comment

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

Thanks! This is close, have a few more minor requests though.

Prevents potential backward compatibility issues.
@AnsahMohammad AnsahMohammad requested a review from ahal March 13, 2025 12:11
@AnsahMohammad
Copy link
Contributor Author

Thanks! This is close, have a few more minor requests though.

I've addressed the comments, please review again.

Copy link
Collaborator

@ahal ahal left a comment

Choose a reason for hiding this comment

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

Apologies for the delayed review!

@@ -1061,6 +1069,9 @@ def main(args):
parser.add_argument("--user", default="worker", help="user to run as")
parser.add_argument("--group", default="worker", help="group to run as")
parser.add_argument("--task-cwd", help="directory to run the provided command in")
parser.add_argument("--shallow", action="store_true",
default=False, help="perform a shallow clone (default: false)",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm really sorry, I told you to add an argument here. But on closer look, I was wrong and instead we should add this in collect_vcs_options using an environment variable like most of the other vcs arguments. You should add something like:

shallow = os.environ.get("%s_SHALLOW_CLONE" % env_prefix)

and make sure to return it (like you already are).

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.

[run-task] Support Git shallow clones
2 participants