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

[Pre-Commit] Continue Even if Fetch Failed #3878

Merged
merged 11 commits into from
Jan 30, 2024
6 changes: 6 additions & 0 deletions .changelog/3878.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changes:
- description: Fixed an issue where the **pre-commit** command would fail if there are connection issues with the git repository.
MichaelYochpaz marked this conversation as resolved.
Show resolved Hide resolved
type: fix
- description: Fixed an issue where if running `git fetch` would fail on `git_util._get_all_changed_files`, an error would be raised.
type: internal
MichaelYochpaz marked this conversation as resolved.
Show resolved Hide resolved
pr_number: 3878
11 changes: 10 additions & 1 deletion demisto_sdk/commands/common/git_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
DEMISTO_GIT_UPSTREAM,
PACKS_FOLDER,
)
from demisto_sdk.commands.common.logger import logger
MichaelYochpaz marked this conversation as resolved.
Show resolved Hide resolved


class CommitOrBranchNotFoundError(GitError):
Expand Down Expand Up @@ -624,7 +625,15 @@ def _get_all_changed_files(self, prev_ver: str = "") -> Set[Path]:
Returns:
Set: of Paths to files changed in the current branch.
"""
self.fetch()
try:
self.fetch()

except Exception as e:
logger.warning(
"Failed to fetch remote branch. Continuing without fetching."
MichaelYochpaz marked this conversation as resolved.
Show resolved Hide resolved
)
logger.debug(f"Error: {e}")

remote, branch = self.handle_prev_ver(prev_ver)
current_hash = self.get_current_commit_hash()

Expand Down
Loading