translations: Fix external translations logic
authorLuís Pereira <luis.artur.pereira@gmail.com>
Wed, 27 Apr 2016 15:50:16 +0000 (16:50 +0100)
committerPalo Kisa <palo.kisa@gmail.com>
Thu, 28 Apr 2016 17:31:37 +0000 (19:31 +0200)
- Don't try to remove non existing files (If the file doesn't exists
ex_result will contain an error message and fail.)

- Make sure git init doesn't fail (If ${TR_TRANSLATION_DIR} doesn't
exist, git init will fail.)

cmake/modules/LXQtTranslateTs.cmake

index e2c5052..6b5e65b 100644 (file)
@@ -168,14 +168,19 @@ function(lxqt_translate_ts qmFiles)
         endif ()
         if (NOT EXISTS "${TR_TRANSLATION_DIR}/${TR_REPO_SUBDIR}")
             message(STATUS "Setting git repository in the translations dir '${TR_TRANSLATION_DIR}' ...")
+            if (EXISTS "${TR_TRANSLATION_DIR}/.git")
+                execute_process(COMMAND rm -Rf .git
+                    WORKING_DIRECTORY  "${TR_TRANSLATION_DIR}"
+                    RESULT_VARIABLE ex_result
+                    )
 
-            execute_process(COMMAND rm -Rf .git
-                WORKING_DIRECTORY  "${TR_TRANSLATION_DIR}"
-                RESULT_VARIABLE ex_result
-                )
-            if (NOT "${ex_result}" EQUAL 0)
-                message(FATAL_ERROR "Initialization(cleanup) of translations dir failed!")
-            endif ()
+                if (NOT "${ex_result}" EQUAL 0)
+                    message(FATAL_ERROR "Initialization(cleanup) of translations dir failed!")
+                endif ()
+            endif()
+
+            # make sure the dir exist, otherwise git init will fail
+            file(MAKE_DIRECTORY "${TR_TRANSLATION_DIR}")
 
             execute_process(COMMAND "${GIT_EXECUTABLE}" init
                 WORKING_DIRECTORY  "${TR_TRANSLATION_DIR}"