Compare commits
2 Commits
8ba7242861
...
v0.2.14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a8fa563dd | ||
|
|
998f7a4f44 |
@@ -475,104 +475,6 @@ read_index() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
write_index() {
|
|
||||||
local base="$1"
|
|
||||||
local pm_agent="$2"
|
|
||||||
local issues_json="$3"
|
|
||||||
local temp_file="$INDEX_FILE.tmp.$$"
|
|
||||||
printf '{"base": %s, "pm_agent": %s, "issues": %s}\n' "$base" "$pm_agent" "$issues_json" > "$temp_file"
|
|
||||||
|
|
||||||
if ! python3 -c "import json; json.load(open('$temp_file'))" 2>/dev/null; then
|
|
||||||
echo "Error: write_index would create malformed JSON, aborting. base=$base, pm_agent=$pm_agent, issues_json=$issues_json" >&2
|
|
||||||
rm -f "$temp_file"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mv "$temp_file" "$INDEX_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_base_session_id() {
|
|
||||||
local index=$(read_index)
|
|
||||||
echo "$index" | python3 -c "import sys, json; d=json.load(sys.stdin); print(d.get('base') or '')"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_pm_agent_session_id() {
|
|
||||||
local index=$(read_index)
|
|
||||||
echo "$index" | python3 -c "import sys, json; d=json.load(sys.stdin); print(d.get('pm_agent') or '')"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_session_for_issue() {
|
|
||||||
local issue_ref="$1"
|
|
||||||
local index=$(read_index)
|
|
||||||
echo "$index" | python3 -c "import sys, json; d=json.load(sys.stdin); print(d['issues'].get('$issue_ref') or '')"
|
|
||||||
}
|
|
||||||
|
|
||||||
set_base_in_index() {
|
|
||||||
local base_session_id="$1"
|
|
||||||
local pm_agent=$(get_pm_agent_session_id)
|
|
||||||
local issues_json=$(read_index | python3 -c "import sys, json; d=json.load(sys.stdin); print(json.dumps(d['issues']))")
|
|
||||||
if [ -z "$pm_agent" ] || [ "$pm_agent" = "null" ]; then
|
|
||||||
write_index "\"$base_session_id\"" "null" "$issues_json"
|
|
||||||
else
|
|
||||||
write_index "\"$base_session_id\"" "\"$pm_agent\"" "$issues_json"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_pm_agent_in_index() {
|
|
||||||
local pm_agent_session_id="$1"
|
|
||||||
local base=$(get_base_session_id)
|
|
||||||
local issues_json=$(read_index | python3 -c "import sys, json; d=json.load(sys.stdin); print(json.dumps(d['issues']))")
|
|
||||||
if [ -z "$base" ] || [ "$base" = "null" ]; then
|
|
||||||
write_index "null" "\"$pm_agent_session_id\"" "$issues_json"
|
|
||||||
else
|
|
||||||
write_index "\"$base\"" "\"$pm_agent_session_id\"" "$issues_json"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
add_issue_to_index() {
|
|
||||||
local issue_ref="$1"
|
|
||||||
local session_file="$2"
|
|
||||||
local index=$(read_index)
|
|
||||||
local base=$(get_base_session_id)
|
|
||||||
local pm_agent=$(get_pm_agent_session_id)
|
|
||||||
local issues=$(echo "$index" | python3 -c "import sys, json; d=json.load(sys.stdin); print(json.dumps(d['issues']))")
|
|
||||||
local new_issues=$(echo "$issues" | python3 -c "import sys, json; d=json.load(sys.stdin); d['$issue_ref']='$session_file'; print(json.dumps(d))")
|
|
||||||
if [ -z "$base" ] || [ "$base" = "null" ]; then
|
|
||||||
if [ -z "$pm_agent" ] || [ "$pm_agent" = "null" ]; then
|
|
||||||
write_index "null" "null" "$new_issues"
|
|
||||||
else
|
|
||||||
write_index "null" "\"$pm_agent\"" "$new_issues"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -z "$pm_agent" ] || [ "$pm_agent" = "null" ]; then
|
|
||||||
write_index "\"$base\"" "null" "$new_issues"
|
|
||||||
else
|
|
||||||
write_index "\"$base\"" "\"$pm_agent\"" "$new_issues"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_issue_from_index() {
|
|
||||||
local issue_ref="$1"
|
|
||||||
local index=$(read_index)
|
|
||||||
local base=$(get_base_session_id)
|
|
||||||
local pm_agent=$(get_pm_agent_session_id)
|
|
||||||
local new_issues=$(echo "$index" | python3 -c "import sys, json; d=json.load(sys.stdin); d['issues'].pop('$issue_ref', None); print(json.dumps(d['issues']))")
|
|
||||||
if [ -z "$base" ] || [ "$base" = "null" ]; then
|
|
||||||
if [ -z "$pm_agent" ] || [ "$pm_agent" = "null" ]; then
|
|
||||||
write_index "null" "null" "$new_issues"
|
|
||||||
else
|
|
||||||
write_index "null" "\"$pm_agent\"" "$new_issues"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -z "$pm_agent" ] || [ "$pm_agent" = "null" ]; then
|
|
||||||
write_index "\"$base\"" "null" "$new_issues"
|
|
||||||
else
|
|
||||||
write_index "\"$base\"" "\"$pm_agent\"" "$new_issues"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_issue_ref() {
|
validate_issue_ref() {
|
||||||
local issue_ref="$1"
|
local issue_ref="$1"
|
||||||
if [[ ! "$issue_ref" =~ ^[^/]+/[^/]+/[^#]+#[0-9]+$ ]]; then
|
if [[ ! "$issue_ref" =~ ^[^/]+/[^/]+/[^#]+#[0-9]+$ ]]; then
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ set_base_in_index() {
|
|||||||
if [ "$session_id" = "null" ]; then
|
if [ "$session_id" = "null" ]; then
|
||||||
write_index "null" "$pm_agent" "$issues"
|
write_index "null" "$pm_agent" "$issues"
|
||||||
else
|
else
|
||||||
write_index "\"$session_id\"" "$pm_agent" "$issues"
|
if [ "$pm_agent" = "null" ]; then
|
||||||
|
write_index "\"$session_id\"" "null" "$issues"
|
||||||
|
else
|
||||||
|
write_index "\"$session_id\"" "\"$pm_agent\"" "$issues"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +67,11 @@ set_pm_agent_in_index() {
|
|||||||
if [ "$session_id" = "null" ]; then
|
if [ "$session_id" = "null" ]; then
|
||||||
write_index "$base" "null" "$issues"
|
write_index "$base" "null" "$issues"
|
||||||
else
|
else
|
||||||
write_index "$base" "\"$session_id\"" "$issues"
|
if [ "$base" = "null" ]; then
|
||||||
|
write_index "null" "\"$session_id\"" "$issues"
|
||||||
|
else
|
||||||
|
write_index "\"$base\"" "\"$session_id\"" "$issues"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +87,19 @@ add_issue_to_index() {
|
|||||||
|
|
||||||
issues=$(python3 -c "import sys, json; d=json.load(sys.stdin); d['$issue_ref']='$session_file'; print(json.dumps(d))" <<< "$issues")
|
issues=$(python3 -c "import sys, json; d=json.load(sys.stdin); d['$issue_ref']='$session_file'; print(json.dumps(d))" <<< "$issues")
|
||||||
|
|
||||||
write_index "$base" "$pm_agent" "$issues"
|
if [ "$base" = "null" ]; then
|
||||||
|
if [ "$pm_agent" = "null" ]; then
|
||||||
|
write_index "null" "null" "$issues"
|
||||||
|
else
|
||||||
|
write_index "null" "\"$pm_agent\"" "$issues"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$pm_agent" = "null" ]; then
|
||||||
|
write_index "\"$base\"" "null" "$issues"
|
||||||
|
else
|
||||||
|
write_index "\"$base\"" "\"$pm_agent\"" "$issues"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_issue_from_index() {
|
remove_issue_from_index() {
|
||||||
@@ -93,7 +113,19 @@ remove_issue_from_index() {
|
|||||||
|
|
||||||
issues=$(python3 -c "import sys, json; d=json.load(sys.stdin); d.pop('$issue_ref', None); print(json.dumps(d))" <<< "$issues")
|
issues=$(python3 -c "import sys, json; d=json.load(sys.stdin); d.pop('$issue_ref', None); print(json.dumps(d))" <<< "$issues")
|
||||||
|
|
||||||
write_index "$base" "$pm_agent" "$issues"
|
if [ "$base" = "null" ]; then
|
||||||
|
if [ "$pm_agent" = "null" ]; then
|
||||||
|
write_index "null" "null" "$issues"
|
||||||
|
else
|
||||||
|
write_index "null" "\"$pm_agent\"" "$issues"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$pm_agent" = "null" ]; then
|
||||||
|
write_index "\"$base\"" "null" "$issues"
|
||||||
|
else
|
||||||
|
write_index "\"$base\"" "\"$pm_agent\"" "$issues"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_issue_ref() {
|
validate_issue_ref() {
|
||||||
|
|||||||
Reference in New Issue
Block a user