-
-
Notifications
You must be signed in to change notification settings - Fork 251
Feature/fuzzy search logic #556
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
Open
danielrosehill
wants to merge
5
commits into
sysadminsmedia:main
Choose a base branch
from
danielrosehill:feature/fuzzy-search-logic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41bf881
updated
danielrosehill 43f2336
Merge branch 'sysadminsmedia:main' into main
danielrosehill 59b6c1e
Add script to create and update docker testing branch
danielrosehill 7dd9703
Add script to create feature test branches
danielrosehill 1bbbd97
fuzzy search
danielrosehill 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package repo | ||
|
|
||
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/agext/levenshtein" | ||
| ) | ||
|
|
||
| // FuzzyMatch checks if a string matches a query with fuzzy matching | ||
| // using Levenshtein distance algorithm | ||
| func FuzzyMatch(str, query string, threshold float64) bool { | ||
| if query == "" { | ||
| return true | ||
| } | ||
|
|
||
| // Convert to lowercase for case-insensitive comparison | ||
| str = strings.ToLower(str) | ||
| query = strings.ToLower(query) | ||
|
|
||
| // Check if the query is a substring of the string | ||
| if strings.Contains(str, query) { | ||
| return true | ||
| } | ||
|
|
||
| // Calculate Levenshtein distance | ||
| distance := levenshtein.Distance(str, query, nil) | ||
|
|
||
| // Normalize the distance based on the length of the longer string | ||
| maxLen := len(str) | ||
| if len(query) > maxLen { | ||
| maxLen = len(query) | ||
| } | ||
|
|
||
| if maxLen == 0 { | ||
| return true | ||
| } | ||
|
|
||
| // Calculate similarity ratio (0.0 to 1.0) | ||
| similarity := 1.0 - float64(distance)/float64(maxLen) | ||
|
|
||
| // Return true if similarity is above the threshold | ||
| return similarity >= threshold | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/bin/bash | ||
|
|
||
| # create-feature-test-branch.sh | ||
| # Script to create a test branch for a specific feature based on docker/custom-image | ||
|
|
||
| set -e # Exit on error | ||
|
|
||
| # Check if a feature branch was provided | ||
| if [ $# -lt 1 ]; then | ||
| echo "Usage: $0 <feature-branch-name> [test-branch-suffix]" | ||
| echo "Example: $0 feature/homepage-accordions test" | ||
| echo "This will create docker/testing-homepage-accordions-test branch" | ||
| exit 1 | ||
| fi | ||
|
|
||
| FEATURE_BRANCH=$1 | ||
| TEST_SUFFIX=${2:-test} # Default suffix is "test" if not provided | ||
|
|
||
| # Extract the feature name from the branch name | ||
| if [[ $FEATURE_BRANCH == feature/* ]]; then | ||
| FEATURE_NAME=${FEATURE_BRANCH#feature/} | ||
| else | ||
| FEATURE_NAME=$FEATURE_BRANCH | ||
| fi | ||
|
|
||
| # Create a properly named test branch | ||
| TEST_BRANCH="docker/testing-${FEATURE_NAME}-${TEST_SUFFIX}" | ||
|
|
||
| # Base branch for testing | ||
| BASE_BRANCH="docker/custom-image" | ||
|
|
||
| echo "Creating test branch $TEST_BRANCH based on $BASE_BRANCH with feature $FEATURE_BRANCH" | ||
|
|
||
| # Make sure we're starting from a clean state | ||
| git fetch origin | ||
| git checkout $BASE_BRANCH | ||
| git pull origin $BASE_BRANCH || true # Continue even if there's no remote tracking | ||
|
|
||
| # Create the test branch | ||
| if git show-ref --verify --quiet refs/heads/$TEST_BRANCH; then | ||
| echo "Branch $TEST_BRANCH already exists. Resetting it to match $BASE_BRANCH." | ||
| git checkout $TEST_BRANCH | ||
| git reset --hard $BASE_BRANCH | ||
| else | ||
| echo "Creating new branch $TEST_BRANCH from $BASE_BRANCH." | ||
| git checkout -b $TEST_BRANCH $BASE_BRANCH | ||
| fi | ||
|
|
||
| # Check if the feature branch exists | ||
| if ! git show-ref --verify --quiet refs/heads/$FEATURE_BRANCH; then | ||
| echo "Error: Feature branch $FEATURE_BRANCH does not exist." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Try to cherry-pick or merge the feature branch | ||
| echo "Attempting to cherry-pick commits from $FEATURE_BRANCH..." | ||
|
|
||
| # Get the commit hash of the latest commit in the feature branch | ||
| FEATURE_COMMIT=$(git rev-parse $FEATURE_BRANCH) | ||
|
|
||
| # Try cherry-picking | ||
| if git cherry-pick $FEATURE_COMMIT; then | ||
| echo "✅ Successfully cherry-picked $FEATURE_BRANCH" | ||
| else | ||
| echo "⚠️ Cherry-pick failed. Trying merge instead..." | ||
| git cherry-pick --abort | ||
|
|
||
| if git merge --no-ff $FEATURE_BRANCH -m "Merge $FEATURE_BRANCH into $TEST_BRANCH for testing"; then | ||
| echo "✅ Successfully merged $FEATURE_BRANCH" | ||
| else | ||
| echo "⚠️ Merge failed as well. Manual intervention required." | ||
| echo "Please resolve conflicts and commit the changes." | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo "Test branch $TEST_BRANCH created and updated with $FEATURE_BRANCH!" | ||
| echo "You can now build and test your Docker image from this branch:" | ||
| echo "docker build -t homebox-testing-${FEATURE_NAME} ." |
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.
Why is this not awaited any more?