This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/aitimemachine/git/contrib/coverage-diff.sh
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

104 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# Usage: Run 'contrib/coverage-diff.sh <version1> <version2>' from source-root
# after running
#
# make coverage-test
# make coverage-report
#
# while checked out at <version2>. This script combines the *.gcov files
# generated by the 'make' commands above with 'git diff <version1> <version2>'
# to report new lines that are not covered by the test suite.
V1=$1
V2=$2
diff_lines () {
perl -e '
my $line_num;
while (<>) {
# Hunk header? Grab the beginning in postimage.
if (/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/) {
$line_num = $1;
next;
}
# Have we seen a hunk? Ignore "diff --git" etc.
next unless defined $line_num;
# Deleted line? Ignore.
if (/^-/) {
next;
}
# Show only the line number of added lines.
if (/^\+/) {
print "$line_num\n";
}
# Either common context or added line appear in
# the postimage. Count it.
$line_num++;
}
'
}
files=$(git diff --name-only "$V1" "$V2" -- \*.c)
# create empty file
>coverage-data.txt
for file in $files
do
git diff "$V1" "$V2" -- "$file" |
diff_lines |
sort >new_lines.txt
if ! test -s new_lines.txt
then
continue
fi
hash_file=$(echo $file | sed "s/\//\#/")
if ! test -s "$hash_file.gcov"
then
continue
fi
sed -ne '/#####:/{
s/ #####://
s/:.*//
s/ //g
p
}' "$hash_file.gcov" |
sort >uncovered_lines.txt
comm -12 uncovered_lines.txt new_lines.txt |
sed -e 's/$/\)/' -e 's/^/ /' >uncovered_new_lines.txt
grep -q '[^[:space:]]' <uncovered_new_lines.txt &&
echo $file >>coverage-data.txt &&
git blame -s "$V2" -- "$file" |
sed 's/\t//g' |
grep -f uncovered_new_lines.txt >>coverage-data.txt &&
echo >>coverage-data.txt
rm -f new_lines.txt uncovered_lines.txt uncovered_new_lines.txt
done
cat coverage-data.txt
echo "Commits introducing uncovered code:"
commit_list=$(awk '/^[0-9a-f]{7,}/ { print $1 }' coverage-data.txt | sort -u)
(
for commit in $commit_list
do
git log --no-decorate --pretty=format:'%an %h: %s' -1 $commit
echo
done
) | sort
rm coverage-data.txt