-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(git): add subdir support to GitReference #12131
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6d6a869
feat(git): add subdir support to GitReference
devin-ai-integration[bot] ce19eb9
refactor(git): rename subdir to url_path_prefix and simplify implemen…
devin-ai-integration[bot] eef7aae
test(git): add edge case tests for url_path_prefix
devin-ai-integration[bot] f861acb
test(git): fix formatting in test_git_clone.py
devin-ai-integration[bot] b336629
fixup
hsheth2 25e543e
Merge branch 'master' into hs--cus-3397
hsheth2 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import os | ||
import pathlib | ||
|
||
import pytest | ||
from pydantic import SecretStr | ||
|
@@ -12,7 +13,7 @@ | |
LOOKML_TEST_SSH_KEY = os.environ.get("DATAHUB_LOOKML_GIT_TEST_SSH_KEY") | ||
|
||
|
||
def test_base_url_guessing(): | ||
def test_base_url_guessing() -> None: | ||
# Basic GitHub repo. | ||
config = GitInfo(repo="https://github.com/datahub-project/datahub", branch="master") | ||
assert config.repo_ssh_locator == "[email protected]:datahub-project/datahub.git" | ||
|
@@ -70,7 +71,7 @@ def test_base_url_guessing(): | |
) | ||
|
||
|
||
def test_github_branch(): | ||
def test_github_branch() -> None: | ||
config = GitInfo( | ||
repo="owner/repo", | ||
) | ||
|
@@ -83,11 +84,37 @@ def test_github_branch(): | |
assert config.branch_for_clone == "main" | ||
|
||
|
||
def test_url_subdir() -> None: | ||
git_ref = GitReference(repo="https://github.com/org/repo", url_subdir="dbt") | ||
assert ( | ||
git_ref.get_url_for_file_path("model.sql") | ||
== "https://github.com/org/repo/blob/main/dbt/model.sql" | ||
) | ||
|
||
git_ref = GitReference(repo="https://gitlab.com/org/repo", url_subdir="dbt") | ||
assert ( | ||
git_ref.get_url_for_file_path("model.sql") | ||
== "https://gitlab.com/org/repo/-/blob/main/dbt/model.sql" | ||
) | ||
|
||
git_ref = GitReference(repo="https://github.com/org/repo", url_subdir="") | ||
assert ( | ||
git_ref.get_url_for_file_path("model.sql") | ||
== "https://github.com/org/repo/blob/main/model.sql" | ||
) | ||
|
||
git_ref = GitReference(repo="https://github.com/org/repo", url_subdir="dbt/models") | ||
assert ( | ||
git_ref.get_url_for_file_path("model.sql") | ||
== "https://github.com/org/repo/blob/main/dbt/models/model.sql" | ||
) | ||
|
||
|
||
def test_sanitize_repo_url() -> None: | ||
assert_doctest(datahub.ingestion.source.git.git_import) | ||
|
||
|
||
def test_git_clone_public(tmp_path): | ||
def test_git_clone_public(tmp_path: pathlib.Path) -> None: | ||
git_clone = GitClone(str(tmp_path)) | ||
checkout_dir = git_clone.clone( | ||
ssh_key=None, | ||
|
@@ -107,7 +134,7 @@ def test_git_clone_public(tmp_path): | |
LOOKML_TEST_SSH_KEY is None, | ||
reason="DATAHUB_LOOKML_GIT_TEST_SSH_KEY env variable is not configured", | ||
) | ||
def test_git_clone_private(tmp_path): | ||
def test_git_clone_private(tmp_path: pathlib.Path) -> None: | ||
git_clone = GitClone(str(tmp_path)) | ||
secret_key = SecretStr(LOOKML_TEST_SSH_KEY) if LOOKML_TEST_SSH_KEY else None | ||
|
||
|
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'm not familiar with gitlab and this
-
in the middle called my attention.Apparently, the dashless variant also works https://gitlab.com/gitlab-org/gitlab/-/issues/365984
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.
huh interesting
The
/-/
stuff was already in there, and given that it still works, I don't think it makes sense to change right now