summaryrefslogtreecommitdiffstats
path: root/translations/git-stage-script.cmake
blob: f80d9603d0850fecc8b6777ebe54b6a371a5e723 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#
# CMake script to collect and stage modified .ts files to git
#

if (NOT LCONVERT_BIN)
    message(FATAL_ERROR "lconvert binary not specified. Use LCONVERT_BIN to pass in a value")
endif()


set(output_file ".git_stage_files.txt")

execute_process(
    COMMAND git diff-files --name-only "*.ts"
    OUTPUT_FILE ${output_file}
    RESULT_VARIABLE git_result
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT git_result EQUAL 0)
    message(FATAL_ERROR "'git diff-files --name-only *.ts' exited with non-zero status.")
endif()

file(STRINGS ${output_file} file_list)
foreach (file IN LISTS file_list)
    execute_process(
        COMMAND ${LCONVERT_BIN} -locations none -i "${file}" -o "${file}"
        RESULT_VARIABLE lconvert_result
        COMMAND_ECHO STDOUT
    )
    if (NOT lconvert_result EQUAL 0)
        message(FATAL_ERROR "Command exited with non-zero status.")
    endif()
endforeach()

execute_process(
    COMMAND git add ${file_list}
    RESULT_VARIABLE git_result
    COMMAND_ECHO STDOUT
)

if (NOT git_result EQUAL 0)
    message(FATAL_ERROR "Command exited with non-zero status.")
endif()

if (file_list)
    message("Translation files added to git. Please commit them to finish.")
endif()