Do not apply patches if sub non-git repo is located in a git repo. (#… · intel/opencl-clang@470cf00 (original) (raw)
`@@ -87,7 +87,7 @@ endfunction()
`
87
87
`` # Then all patches from the patches_dir
are committed to the target_branch
.
``
88
88
`` # Does nothing if the target_branch
is already checked out in the repo_dir
.
``
89
89
`#
`
90
``
`-
function(apply_patches repo_dir patches_dir base_revision target_branch ret)
`
``
90
`+
function(apply_patches repo_dir patches_dir base_revision target_branch)
`
91
91
` foreach(patches_dir ${patches_dir})
`
92
92
` file(GLOB patches_in_dir ${patches_dir}/*.patch)
`
93
93
` list(APPEND patches ${patches_in_dir})
`
`@@ -97,19 +97,20 @@ function(apply_patches repo_dir patches_dir base_revision target_branch ret)
`
97
97
` return()
`
98
98
` endif()
`
99
99
``
100
``
`-
message(STATUS "[OPENCL-CLANG] Patching repository ${repo_dir}")
`
``
100
`+
Check if it's a git repo
`
``
101
`+
if(EXISTS "${repo_dir}/.git")
`
``
102
`+
message(STATUS "[OPENCL-CLANG] Patching repository ${repo_dir}")
`
``
103
`+
else()
`
``
104
`+
message(STATUS "[OPENCL-CLANG][Warning] ${repo_dir} is not a git repository, therefore, local patches are not applied")
`
``
105
`+
return()
`
``
106
`+
endif()
`
101
107
`# Check if the target branch already exists
`
102
108
` execute_process(
`
103
109
`COMMAND GITEXECUTABLErev−parse−−verify−−no−revs−q{GIT_EXECUTABLE} rev-parse --verify --no-revs -q GITEXECUTABLErev−parse−−verify−−no−revs−q{target_branch}
`
104
110
`WORKING_DIRECTORY ${repo_dir}
`
105
111
`RESULT_VARIABLE patches_needed
`
106
112
`OUTPUT_QUIET
`
107
113
` )
`
108
``
`-
if(patches_needed EQUAL 128) # not a git repo
`
109
``
`-
set(${ret} True PARENT_SCOPE)
`
110
``
`-
message(STATUS "[OPENCL-CLANG][Warning] ${repo_dir} is not a git repository, therefore, local patches are not applied")
`
111
``
`-
return()
`
112
``
`-
endif()
`
113
114
` if(patches_needed EQUAL 1) # The target branch doesn't exist
`
114
115
` list(SORT patches)
`
115
116
` is_valid_revision(${repo_dir} ${base_revision} exists_base_rev)
`
`@@ -159,7 +160,7 @@ function(apply_patches repo_dir patches_dir base_revision target_branch ret)
`
159
160
` )
`
160
161
` endif()
`
161
162
` if (NOT (ret_check_out OR ret_apply_patch))
`
162
``
`-
set(${ret} True PARENT_SCOPE)
`
``
163
`+
message(STATUS "[OPENCL-CLANG] Applied patch successfully!")
`
163
164
` else()
`
164
165
` message(FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!")
`
165
166
` endif()
`