Skip to content

Commit

Permalink
Merge pull request #3157 from wazuh/3154-commit-option-fix-4.4
Browse files Browse the repository at this point in the history
Enhancement - Fix test scan commit option
  • Loading branch information
jmv74211 authored Sep 22, 2022
2 parents bde8608 + 2e8eb6c commit 5f567ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Release report: TBD

### Fixed

- Fix commit option of the scan module for master case ([#3157](https:/wazuh/wazuh-qa/pull/3157)) \- (Tests)
- Fix Vulnerability Detector IT: test_validate_feed_content yaml cases had wrong extension. ([#3299](https:/wazuh/wazuh-qa/pull/3299)) \- (Tests)
- Fix Analysisd IT: test_syscollector_events failure on wait_for_analysisd_startup. ([#3110](https:/wazuh/wazuh-qa/pull/3110)) \- (Tests)
- Fix GCloud IT: test_max_messages error not received expected messages - ([#3083](https:/wazuh/wazuh-qa/pull/3083)) \- (Tests)
Expand Down
18 changes: 14 additions & 4 deletions tests/scans/code_analysis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ def clone_wazuh_repository(pytestconfig):
repo = Repo.clone_from(f"https:/wazuh/{repository_name}.git",
repository_path, branch='master', no_single_branch=True)

# Get all branches that contains the commit
git_local = Git(repository_path)
commit_branch = git_local.branch('-a', '--contains', commit).split('\n')[0].strip()

repo.git.checkout(commit_branch)
repo.git.checkout(commit)
commit_branch = git_local.branch('-a', '--contains', commit).split('\n')
commit_branch_head = False

for branch in commit_branch:
# Remove * in case of branch is the master
branch_name = branch.replace('*', '').strip()
repo.git.checkout(branch_name)
# Check if the commit is the head of the branch
if(str(repo.head.commit) == commit):
commit_branch_head = True
break
if not commit_branch_head:
raise Exception(f"{commit} was not found as any head branch")

yield repository_path

Expand Down

0 comments on commit 5f567ef

Please sign in to comment.