mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-19 10:52:28 +08:00
fix: prevent gstack-relink from double-prefixing gstack-upgrade
gstack-relink now checks if a skill directory is already named gstack-* before prepending the prefix. Previously, setting skill_prefix=true would create gstack-gstack-upgrade, breaking the /gstack-upgrade command. Matches setup script behavior (setup:260) which already has this guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,13 +46,22 @@ for skill_dir in "$INSTALL_DIR"/*/; do
|
|||||||
[ -f "$skill_dir/SKILL.md" ] || continue
|
[ -f "$skill_dir/SKILL.md" ] || continue
|
||||||
|
|
||||||
if [ "$PREFIX" = "true" ]; then
|
if [ "$PREFIX" = "true" ]; then
|
||||||
# Create gstack-* symlink, remove flat if exists
|
# Don't double-prefix directories already named gstack-*
|
||||||
ln -sfn "$INSTALL_DIR/$skill" "$SKILLS_DIR/gstack-$skill"
|
case "$skill" in
|
||||||
[ -L "$SKILLS_DIR/$skill" ] && rm -f "$SKILLS_DIR/$skill"
|
gstack-*) link_name="$skill" ;;
|
||||||
|
*) link_name="gstack-$skill" ;;
|
||||||
|
esac
|
||||||
|
ln -sfn "$INSTALL_DIR/$skill" "$SKILLS_DIR/$link_name"
|
||||||
|
# Remove old flat symlink if it exists (and isn't the same as the new link)
|
||||||
|
[ "$link_name" != "$skill" ] && [ -L "$SKILLS_DIR/$skill" ] && rm -f "$SKILLS_DIR/$skill"
|
||||||
else
|
else
|
||||||
# Create flat symlink, remove gstack-* if exists
|
# Create flat symlink, remove gstack-* if exists
|
||||||
ln -sfn "$INSTALL_DIR/$skill" "$SKILLS_DIR/$skill"
|
ln -sfn "$INSTALL_DIR/$skill" "$SKILLS_DIR/$skill"
|
||||||
[ -L "$SKILLS_DIR/gstack-$skill" ] && rm -f "$SKILLS_DIR/gstack-$skill"
|
# Don't remove gstack-* dirs that are their real name (e.g., gstack-upgrade)
|
||||||
|
case "$skill" in
|
||||||
|
gstack-*) ;; # Already the real name, no old prefixed link to clean
|
||||||
|
*) [ -L "$SKILLS_DIR/gstack-$skill" ] && rm -f "$SKILLS_DIR/gstack-$skill" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
SKILL_COUNT=$((SKILL_COUNT + 1))
|
SKILL_COUNT=$((SKILL_COUNT + 1))
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -122,6 +122,21 @@ describe('gstack-relink (#578)', () => {
|
|||||||
expect(output).toContain('setup');
|
expect(output).toContain('setup');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Test: gstack-upgrade does NOT get double-prefixed
|
||||||
|
test('does not double-prefix gstack-upgrade directory', () => {
|
||||||
|
setupMockInstall(['qa', 'ship', 'gstack-upgrade']);
|
||||||
|
run(`${path.join(installDir, 'bin', 'gstack-config')} set skill_prefix true`);
|
||||||
|
run(`${path.join(installDir, 'bin', 'gstack-relink')}`, {
|
||||||
|
GSTACK_INSTALL_DIR: installDir,
|
||||||
|
GSTACK_SKILLS_DIR: skillsDir,
|
||||||
|
});
|
||||||
|
// gstack-upgrade should keep its name, NOT become gstack-gstack-upgrade
|
||||||
|
expect(fs.existsSync(path.join(skillsDir, 'gstack-upgrade'))).toBe(true);
|
||||||
|
expect(fs.existsSync(path.join(skillsDir, 'gstack-gstack-upgrade'))).toBe(false);
|
||||||
|
// Regular skills still get prefixed
|
||||||
|
expect(fs.existsSync(path.join(skillsDir, 'gstack-qa'))).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
// Test 15: gstack-config set skill_prefix triggers relink
|
// Test 15: gstack-config set skill_prefix triggers relink
|
||||||
test('gstack-config set skill_prefix triggers relink', () => {
|
test('gstack-config set skill_prefix triggers relink', () => {
|
||||||
setupMockInstall(['qa', 'ship']);
|
setupMockInstall(['qa', 'ship']);
|
||||||
|
|||||||
Reference in New Issue
Block a user