Skip to content

Commit

Permalink
Add try and except blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelYochpaz committed Dec 19, 2023
1 parent 136f29d commit b085333
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog
## Unreleased
* Fixed an issue where if running `git fetch` (which isn't mandatory) would fail on `git_util._get_all_changed_files`, an error would be raised.

## 1.25.0
* Added support to detect automatically the playground-id when running cli commands in xsoar-6.
Expand Down
10 changes: 9 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,8 @@
DEMISTO_GIT_UPSTREAM,
PACKS_FOLDER,
)
from demisto_sdk.commands.common.logger import logger



class CommitOrBranchNotFoundError(GitError):
Expand Down Expand Up @@ -624,7 +626,13 @@ 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. Generating diff without fetching.")
logger.debug(f"Error: {e}")

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

Expand Down

0 comments on commit b085333

Please sign in to comment.