Skip to content

CARRY: Fix fresh repo sync#24

Closed
mjudeikis wants to merge 1 commit into
masterfrom
fix.pub.bot
Closed

CARRY: Fix fresh repo sync#24
mjudeikis wants to merge 1 commit into
masterfrom
fix.pub.bot

Conversation

@mjudeikis
Copy link
Copy Markdown

Attempt to fix publishing bot

cp: cannot stat '.git/packed-refs': No such file or directory

This happens when processing the virtual-workspace-framework repo on the main branch. The script in construct.sh (via util.sh) tries to clean up .git/packed-refs by copying it to a backup, filtering it with awk, and replacing it. But .git/packed-refs doesn't exist in this repo's git directory.

@kcp-ci-bot kcp-ci-bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 13, 2026
@kcp-ci-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xrstf for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 13, 2026
Comment on lines +111 to +116
awk '
NR == 1 {
prev_line_start_with_caret = 0
}
/^[^^]/ {
prev_line_start_with_caret = 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like we are adding whitespace in front of the awk instructions each line. Will awk not be confused by that? Should it be

Suggested change
awk '
NR == 1 {
prev_line_start_with_caret = 0
}
/^[^^]/ {
prev_line_start_with_caret = 0
awk '
NR == 1 {
prev_line_start_with_caret = 0
}
/^[^^]/ {
prev_line_start_with_caret = 0

... etc?

@xmudrii xmudrii closed this Apr 13, 2026
@mjudeikis
Copy link
Copy Markdown
Author

#!/bin/bash
set -e

# Create a fake packed-refs file with some corrupted lines
# (consecutive caret lines, which the awk script should deduplicate)
cat > /tmp/packed-refs-test <<'EOF'
# pack-refs with: peeled fully-peeled sorted
abc123 refs/tags/v1.0.0
^def456
^bad111
xyz789 refs/tags/v2.0.0
^aaa222
bbb333 refs/tags/v3.0.0
EOF

echo "=== Input ==="
cat /tmp/packed-refs-test

echo ""
echo "=== Output (no indentation - original) ==="
awk '
NR == 1 {
    prev_line_start_with_caret = 0
}
/^[^^]/ {
    prev_line_start_with_caret = 0
    print
}
/^\^/ {
    if (!prev_line_start_with_caret) {
        print
    }
    prev_line_start_with_caret = 1
}
' /tmp/packed-refs-test

echo ""
echo "=== Output (with indentation - new) ==="
    awk '
    NR == 1 {
        prev_line_start_with_caret = 0
    }
    /^[^^]/ {
        prev_line_start_with_caret = 0
        print
    }
    /^\^/ {
        if (!prev_line_start_with_caret) {
            print
        }
        prev_line_start_with_caret = 1
    }
    ' /tmp/packed-refs-test

echo ""
echo "=== Diff (should be empty) ==="
diff <(awk '
NR == 1 {
    prev_line_start_with_caret = 0
}
/^[^^]/ {
    prev_line_start_with_caret = 0
    print
}
/^\^/ {
    if (!prev_line_start_with_caret) {
        print
    }
    prev_line_start_with_caret = 1
}
' /tmp/packed-refs-test) <(    awk '
    NR == 1 {
        prev_line_start_with_caret = 0
    }
    /^[^^]/ {
        prev_line_start_with_caret = 0
        print
    }
    /^\^/ {
        if (!prev_line_start_with_caret) {
            print
        }
        prev_line_start_with_caret = 1
    }
    ' /tmp/packed-refs-test) && echo "PASS: outputs are identical" || echo "FAIL: outputs differ"

rm /tmp/packed-refs-test

Awk should not care about this, as it cares about what's between ''. Some test script I used to test this.

This does not happen in upstream (I assume this) as upstream never starts with a bare/empty repo? They do the initial sync by hand, for example, here: https://github.com/kubernetes/streaming/commits/master/

If you come up with a different fix to this, without touching https://github.com/kcp-dev/virtual-workspace-framework and making it not empty - sure, lets close it :)

@xmudrii
Copy link
Copy Markdown
Member

xmudrii commented Apr 13, 2026

As an update for the future if we ever run into this again: the target repo must have an initial empty commit, with special emphasis on empty (no files, just commit). In this case, the repo had no commits and publishing-bot failed. This is kind of a safeguard against this, among other things.

@xmudrii
Copy link
Copy Markdown
Member

xmudrii commented Apr 13, 2026

Here's an example from upstream from the staging repo that MJ linked above: kubernetes/streaming@6759320

And from one of our repos: kcp-dev/virtual-workspace-framework@3d2afca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants