Files
heartwood/scripts/import-issue.sh
T
Alexis Sellier 3bd5589b1a cob: Stabilize formats
> I'm going to be making a set of breaking changes to COBs in order to
stabilize the data formats. This is hopefully a one-time change that
bundles various breaking changes.

All COBs have been reworked: issue, patch, id.

The changes included are:

* Revise the assign and tag actions to take a single list of
  assignees/tags to set, instead of an "add" and a "remove" list. This
  makes API usage simpler when editing issues, and simplifies the apply
  function
* Rename "tags" to "labels", and the tag action to label. This is
  because tag is confusing in the context of git, as it could mean a git
  tag. Using label removes that confusion.
* Use DIDs instead of PublicKeys for assignees -- this is more
  future-proof
* Modify the manifest file format in the COB tree. Mainly, remove the
  `history_type` key which is redundant, and use camelCase for keys
* Flatten the `Thread` actions into the parent action type
* Ensure that operations on redacted objects do not fail, since
  redactions could have happened concurrently
* Use a consistent naming scheme for actions, using `.` as separator
* Consolidate comment types and remove `CodeComment`, by adding an
  optional `location` field to `Comment`
* Add many placeholder actions that are not yet implemented

To preserve backwards compatibility, a `legacy` module is created with
the old `apply` function. When loading the manifest, we check whether it
is a legacy COB or a "stable" COB, and in the legacy case, use the
legacy code to materialize the state and then convert the object into
the stable type. Eventually, we'll delete the legacy code.
2023-08-07 11:05:14 +02:00

63 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# Import a GitHub issue into Radicle.
#
set -e
if ! command -v curl > /dev/null; then
echo "Error: curl is not installed" ; exit 1
fi
if ! command -v jq > /dev/null; then
echo "Error: jq is not installed" ; exit 1
fi
if ! command -v rad > /dev/null; then
echo "Error: rad is not installed" ; exit 1
fi
if ! command -v pcregrep > /dev/null; then
echo "Error: pcregrep is not installed" ; exit 1
fi
if ! command -v sed > /dev/null; then
echo "Error: sed is not installed" ; exit 1
fi
function removeImgTags {
local html="$(cat)"
local imgTags="$(echo "$html" | pcregrep -M '<img [^>]*>')"
for imgTag in "$imgTags"; do
html="$(echo "$html" | sed -z "s@$imgTag@@")"
done
echo "$html"
}
# Check if the correct number of arguments is provided
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <org> <repo> <issue>"
exit 1
fi
owner="$1"
repo="$2"
issue="$3"
url="https://api.github.com/repos/${owner}/${repo}/issues/${issue}"
# Fetch the issue data using the GitHub API
response="$(curl -s "$url")"
# Extract the title and body from the JSON response
title="$(echo "$response" | jq -r '.title')"
body="$(echo "$response" | jq -r '.body' | removeImgTags)"
labels="$(echo "$response" | jq -r '.labels | .[].name')"
tags=()
for label in $labels; do
tags+=("--label" "$label")
done
rad issue open --title "$title" "${tags[@]}" --description "$body" --no-announce