Files
Open-Shell-Menu/Src/Setup/CreateSourceIndex.bat
T
ge0rdi f66d5ce50b Fix source indexing
`actions/checkout@v6` clones repo from URL that doesn't contain `.git`
at the end.

We were removing last 4 characters of the URL which resulted in wrong `REPO_URL`
in source index and debugger was thus unable to fetch sources.

The fix is to remove last 4 characters of URL only if there is `.git` at the end.
2026-08-30 13:27:52 +02:00

42 lines
1.3 KiB
Batchfile

@echo off
rem CreateSourceIndex.bat <src-root-path>
rem Create source index (write to stdout)
rem Based on information provided here:
rem https://gist.github.com/baldurk/c6feb31b0305125c6d1a
rem expand src root
set SRC_ROOT=%~fdp1
rem get repo url
for /f %%A in ('git remote get-url origin') do set REPO_URL=%%A
rem remove eventual .git from the end
if /I "%REPO_URL:~-4%"==".git" set "REPO_URL=%REPO_URL:~0,-4%"
rem get actual commit id
for /f %%A in ('git rev-parse HEAD') do set COMMIT=%%A
echo SRCSRV: ini ------------------------------------------------
echo VERSION=2
echo VERCTRL=http
echo SRCSRV: variables ------------------------------------------
echo SRCSRVTRG=%REPO_URL%/raw/%COMMIT%/%%var2%%
echo SRCSRV: source files ---------------------------------------
setlocal enabledelayedexpansion
for /f %%A in ('git ls-tree --full-tree -r --name-only head') do (
rem full path to source file
set SRC_FILE=%SRC_ROOT%\%%A
rem replace / by \
set SRC_FILE=!SRC_FILE:/=\!
rem convert to lowercase
for %%C in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do set SRC_FILE=!SRC_FILE:%%C=%%C!
rem <full-path-to-src>*<relative-repo-path>
echo !SRC_FILE!*%%A
)
setlocal disabledelayedexpansion
echo SRCSRV: end ------------------------------------------------