generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 28
feat: allow defining a git service from defaults.ini #694
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
Merged
tromai
merged 10 commits into
staging
from
693-support-defining-a-generic-git-service-through-defaultsini-for-build-tool-detection
Apr 17, 2024
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
24748a1
feat: allow defining a git service from defaults.ini
tromai 4d9adda
test: add integration test
tromai a05ef37
chore: update example and include minor fix
tromai 559041d
chore: fix grammar error
tromai 7c360b0
chore: switch to use both long and short version of CLI flags
tromai 52e50f7
chore: change current workspace to current working directory
tromai ace778c
chore: update terms for repository on the local file system and minor…
tromai d80e19b
chore: rename the name of LocalRepoGitService in its constructor
tromai a96ab2b
chore: change more domain usages to hostname
tromai d2f233e
chore: fix an undefined label
tromai 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
42 changes: 42 additions & 0 deletions
42
src/macaron/slsa_analyzer/git_service/local_repo_git_service.py
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
"""This module contains the spec for the local repo git service.""" | ||
|
||
import logging | ||
|
||
from pydriller.git import Git | ||
|
||
from macaron.errors import ConfigurationError, RepoCheckOutError | ||
from macaron.slsa_analyzer import git_url | ||
from macaron.slsa_analyzer.git_service.base_git_service import BaseGitService | ||
|
||
logger: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
||
class LocalRepoGitService(BaseGitService): | ||
"""This class contains the spec of the local repo git service.""" | ||
|
||
def __init__(self) -> None: | ||
"""Initialize instance.""" | ||
super().__init__("generic") | ||
nathanwn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def load_defaults(self) -> None: | ||
"""Load the values for this git service from the ini configuration.""" | ||
try: | ||
self.hostname = self.load_hostname(section_name="git_service.local_repo") | ||
except ConfigurationError as error: | ||
raise error | ||
|
||
def clone_repo(self, _clone_dir: str, _url: str) -> None: | ||
"""Cloning from a local repo git service is not supported.""" | ||
raise NotImplementedError | ||
|
||
def check_out_repo(self, git_obj: Git, branch: str, digest: str, offline_mode: bool) -> Git: | ||
"""Checkout the branch and commit specified by the user of a repository.""" | ||
if not git_url.check_out_repo_target(git_obj, branch, digest, offline_mode): | ||
raise RepoCheckOutError( | ||
f"Failed to check out branch {branch} and commit {digest} for repo {git_obj.project_name}." | ||
) | ||
|
||
return git_obj |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
[git_service.local_repo] | ||
hostname = bitbucket.org |
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.
Uh oh!
There was an error while loading. Please reload this page.