mirror of
https://github.com/chenasraf/gitlab-search-alfred-workflow.git
synced 2026-05-17 17:48:01 +00:00
feat: add log
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.cache/
|
||||
.DS_Store
|
||||
prefs.plist
|
||||
.cache
|
||||
|
||||
4
log.txt
4
log.txt
@@ -1,4 +0,0 @@
|
||||
Query: compon, Hash: b141f617110529560a69ffb63f881cc5
|
||||
Cache file: .cache/projects-b141f617110529560a69ffb63f881cc5.json
|
||||
Processing results
|
||||
Sending Result: map({title: (["Open Pipeline: ",.path] | join("")), subtitle: .path_with_namespace, arg:([.web_url, "/-/pipelines"] | join(""))}) | {items:.}
|
||||
12
search
12
search
@@ -37,14 +37,16 @@ else
|
||||
find .cache -type f -mtime +7 -name '*.json' -exec rm {} \;
|
||||
|
||||
query=$1
|
||||
hash=$(echo $query | md5 -q)
|
||||
hash=$(echo "$query" | md5 -q)
|
||||
|
||||
log "Query: $query, Hash: $hash"
|
||||
|
||||
log "Query: $query, Hash: $hash"
|
||||
|
||||
# cache file location
|
||||
fl=".cache/projects-$hash.json"
|
||||
|
||||
log "Cache file: $fl"
|
||||
log "Attempting cache file: $fl"
|
||||
|
||||
if [[ ! -f $fl ]]; then
|
||||
log "Cache file not found, fetching from API"
|
||||
@@ -52,13 +54,13 @@ else
|
||||
# project endpoint url
|
||||
url="$API_BASE/$SCOPE/$ID/projects?private_token=$TOKEN&include_subgroups=true&per_page=20&search=$query"
|
||||
# get and cache to file
|
||||
curl $url >$fl
|
||||
curl "$url" >"$fl"
|
||||
fi
|
||||
|
||||
log "Processing results"
|
||||
|
||||
# build url from args and jq result
|
||||
url_build=$([[ -z "$SUFFIX" ]] && echo ".web_url" || echo '([.web_url, "/-/'$SUFFIX'"] | join(""))')
|
||||
url_build=$([[ -z "$SUFFIX" ]] && echo ".web_url" || echo '([.web_url, "/-/'"$SUFFIX"'"] | join(""))')
|
||||
|
||||
# jq query
|
||||
jquery='map({title: (["Open '$URL_DESC': ",.path] | join("")), subtitle: .path_with_namespace, arg:'$url_build'}) | {items:.}'
|
||||
@@ -66,5 +68,5 @@ else
|
||||
log "Sending Result: $jquery"
|
||||
|
||||
# output items to alfred
|
||||
jq "$jquery" $fl
|
||||
jq "$jquery" "$fl"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user