rse/ase / plugin/skills/ase-repo-import
ase-repo-import
VerifiedImport a change set -- a pull/merge request or commit of GitHub, GitLab, or Gitea, given by its URL or by its number `#<number>`, or a diff/patch file -- into the current Git working copy as unstaged and untracked files, merging it with local changes, resolving conflicts semantically, keeping the conflict markers of unresolvable hunks, reporting them as a TODO, and emitting an IMPORTED, CONFLICT, or FAILED verdict. Use when the user calls to "import", "fetch", or "apply" a pull request, merge request, commit, diff, or patch.
@${CLAUDE_SKILL_DIR}/../../meta/ase-control.md @${CLAUDE_SKILL_DIR}/../../meta/ase-skill.md @${CLAUDE_SKILL_DIR}/../../meta/ase-dialog.md @${CLAUDE_SKILL_DIR}/../../meta/ase-getopt.md
$ARGUMENTS
@${CLAUDE_SKILL_DIR}/../../meta/ase-common-resolve.md
Procedure
-
-
Set (empty) and (empty). Set to with any leading and trailing whitespace and any surrounding quotes stripped. If is empty, expand the following:
-
Capture the outputs of the commands
git rev-parse --show-toplevelandgit rev-parse --absolute-git-dir(taken exactly as given) into and . If a command fails, expand the following: -
Run the command
git -C "<repo-root/>" ls-files --unmerged. If its output is not empty, expand the following, as the conflicts of the import could not be told apart from the existing ones: -
Classify into by the first matching form:
-
#<number/>(only digits after the#): set torequest. The form always references the number of the forge and never a task id of ASE. Determine the remotes by running the commandgit -C "<repo-root/>" remoteand set toupstreamif it exists, else tooriginif it exists. Otherwise, expand the following: -
A value starting with
http://orhttps://: remove any?...and#...suffix and match the remainder as<repo-url/>/<path/>, where is one of:-
commit/<sha/>or-/commit/<sha/>, orpull/<number/>/commits/<sha/>orpulls/<number/>/commits/<sha/>: set tocommit. -
pull/<number/>,pulls/<number/>, or-/merge_requests/<number/>, optionally followed by.diff,.patch, or/<anything/>: set torequest.
The URL is valid only if matches the regexp
^https?://[A-Za-z0-9.:-]+(/[A-Za-z0-9._~-]+)+$, consists of digits only, and consists of 7 to 64 hexadecimal digits, which keeps it safe for being passed quoted to thegitcommands. If it is not valid or no form matches, expand the following:Determine the remotes by running the command
git -C "<repo-root/>" remote -vand set to the first remote whose fetch URL denotes the same host and repository path as (ignoring the scheme, the user, and a trailing.git), so its access credentials are used, or to otherwise. -
-
Anything else: set to
fileand to the absolute path of , resolved against the current working directory. If this is no readable regular file, expand the following:
-
-
-
-
-
Capture the default branch of the remote by running the command
git -C "<repo-root/>" fetch --quiet --no-tags "<remote/>" HEADand then the output of the commandgit -C "<repo-root/>" rev-parse FETCH_HEADinto . If a command fails, expand the following: -
Fetch the head by running the command
git -C "<repo-root/>" fetch --quiet --no-tags "<remote/>" "<ref/>", with beingrefs/pull/<number/>/head(GitHub and Gitea) and, if this fails,refs/merge-requests/<number/>/head(GitLab). If both fail, expand the following:Capture the output of the command
git -C "<repo-root/>" rev-parse FETCH_HEADinto . -
Capture the output of the command
git -C "<repo-root/>" merge-base "<default-commit/>" "<head-commit/>"into . This is the fork point from the default branch, as the fork point fromHEADwould import all foreign commits a laggingHEADis missing. If the command fails, expand the following:
Run the command
git -C "<repo-root/>" rev-parse --verify --quiet "<sha/>^{commit}". If it fails, the commit has to be fetched first: run the commandgit -C "<repo-root/>" fetch --quiet --no-tags "<remote/>" "<sha/>"and, if this fails as well (e.g., an abbreviated , which can only be resolved locally), the commandgit -C "<repo-root/>" fetch --quiet --no-tags "<remote/>" HEAD, and then re-run the verification. Capture its output into and the output of the commandgit -C "<repo-root/>" rev-parse --verify --quiet "<head-commit/>^"into . If a verification fails, expand the following: -
-
Set /ase-import.patch and . Create the flattened patch by running the command
git -C "<repo-root/>" diff --no-color --no-ext-diff --src-prefix=a/ --dst-prefix=b/ --binary --full-index -M --output="<patch/>" "<base-commit/>" "<head-commit/>", which is independent of thediff.*configuration of the user, and set -p1. Capture the output of the commandgit -C "<repo-root/>" log --oneline "<base-commit/>..<head-commit/>"into . Keep in mind that the fetch made the blobs of the patch available for the 3-way merge.Set -p1. Read the header of the patch and set to its commit subjects or descriptive text (or to empty if there is none).
-
Run the command
git -C "<repo-root/>" apply <strip/> --numstat -z "<patch/>". If isfileand the command fails or none of the reported paths exists below , while with-p0instead it succeeds and at least one of the reported paths exists, set -p0 and re-run the command.If it still fails (no valid patch) or reports nothing (an empty change set, e.g., of an already merged pull request), expand the following:
-
Only output the following :
-
-
-
Determine the affected files of the patch: set to the paths reported by the
--numstatcommand above and to those reported more than once (a multi-commit patch). Run the commandgit -C "<repo-root/>" apply <strip/> --summary "<patch/>"and set to the mapping of the source to the destination path of itsrenamelines (expanding the compact formdir/{old => new}/file), as--numstat -zreports only the destination. Set to the paths of itscreate modelines plus the destinations of itscopylines, and to the paths of itsdelete modelines. Do not output anything. -
Determine the local changes of the affected files by running the command
git -C "<repo-root/>" -c core.quotepath=off status --porcelain=v1 -- <files/>, with being the quoted paths of and the rename sources of . Set to plus every reported path, with a rename source replaced by its destination. These files bypass the 3-way merge below: it either refuses a file with unstaged changes or merges into its staged state, which the final unstaging would lose, and it nests the conflict markers of a file touched more than once. -
Apply all other files with a 3-way merge by running the command
git -C "<repo-root/>" apply <strip/> --3way --exclude="<file/>" [...] "<patch/>", with one--excludeper file of , and inspect the result. The command is atomic:-
If it succeeded or reported
U <file/>lines (conflict markers written), continue with the next item. -
Otherwise nothing was applied: add every file of an
error: <file/>: <reason/>line to , with a rename source replaced by its destination, and re-run the command. If no line names a further file, expand the following:
-
-
Set to the paths of and the rename sources of , without the files of and their rename sources. Only these got staged by the command above. Do not output anything.
-
-
Apply the hunks of the excluded files directly onto the working directory, leaving their staged state alone, by running the command
git -C "<repo-root/>" apply <strip/> --reject --include="<file/>" [...] "<patch/>", with one--includeper file of . Applicable hunks are applied, also on top of local changes, and the others are rejected. -
Turn every rejected hunk into a conflict in the file, as no base of the 3-way merge exists for it: take the hunks from
<file/>.rej, but for a file of from the rejected sections of the patch, as<file/>.rejholds only the rejects of the last section. Locate the region of the hunk in the current file via its removed and context lines and replace this region by the following, with the labels of a 3-way merge, which you MUST write viaEditwithout changing anything else of the file:<<<<<<< ours [lines of the current region] ||||||| base [removed and context lines of the hunk] ======= [added and context lines of the hunk] >>>>>>> theirsAfterwards, remove
<file/>.rej. If the region of a hunk cannot be located, keep the hunk in<file/>.rej, so it gets escalated below. -
Handle every file which was reported by an
error: <file/>: <reason/>line without any rejected hunk:-
A new file colliding with an existing one (
already exists in working directory): if the existing content equals the content of the patch, nothing has to be done. For different text content, write the existing content and the content of the patch as one conflict spanning the entire file, without abasesection. -
Everything else (e.g., a missing file, the removal of a locally changed file, a binary patch): leave the file untouched and record it in with its conflict kind, a one-line intent of each side, and a one-line reason.
-
-
-
Only output the following :
-
-
-
Set to the paths of , the rename sources of , and all existing
<file/>.rejof them. Do not output anything. -
Resolve the conflicts by expanding the following, where ours are
HEADand the local changes and theirs is the imported change set with the intent :
-
-
-
-
Set to one to three sentences stating what the change set does, derived from the actual changes in (for a large patch, at least from its significant hunks) and not only from the claims of . For every path of , which is relative to , set to
addedif it is in ,removedif it is in ,renamedif it is a destination of , ormodifiedotherwise, followed by, not appliedif left the file untouched. Set to the path, forrenamedprefixed with its rename source and→, and to a short phrase stating what the patch changes in this file. Do not output anything. -
If is not empty, remove it by running the command
rm -rf "<fetched-patch/>". Do not output anything. -
Only output the following , with one table row per path of , grouped in the order
added,modified,renamed, andremoved:Change File Summary <file/>[...] [...] [...] -
Set to plus . Set IMPORTED if is empty, or CONFLICT otherwise. Do not output anything.
-
<file/>:<lines/>(): ◦ ours: ◦ theirs: [...] -
Only output the following :
-
Give the closing hint by expanding the following (which, depending on the configured , may expand into nothing and hence emit no output at all):
-
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |