apache / cordova-common
Showing 1 of 1 files from the diff.

@@ -247,45 +247,35 @@
Loading
247 247
248 248
        const configConflicts = { files: {} }; // config.xml edit-config conflicts
249 249
        const pluginConflicts = { files: {} }; // plugin.xml edit-config conflicts
250 -
        let conflictingParent;
251 -
252 -
        editchanges.forEach(editchange => {
253 -
            if (files[editchange.file]) {
254 -
                const parents = files[editchange.file].parents;
255 -
                let target = parents[editchange.target];
256 -
257 -
                // Check if the edit target will resolve to an existing target
258 -
                if (!target || target.length === 0) {
259 -
                    const targetFile = this.config_keeper.get(this.project_dir, this.platform, editchange.file);
260 -
261 -
                    // For non-XML files (e.g. plist), the selector in editchange.target uniquely identifies its target.
262 -
                    // Thus we already know that we have no conflict if we are not dealing with an XML file here.
263 -
                    if (targetFile.type !== 'xml') return;
264 -
265 -
                    // For XML files, the selector does NOT uniquely identify its target. So we resolve editchange.target
266 -
                    // and any existing selectors to their matched elements and compare those for equality.
267 -
                    const resolveEditTarget = xml_helpers.resolveParent(targetFile.data, editchange.target);
268 -
                    if (resolveEditTarget) {
269 -
                        for (const parent in parents) {
270 -
                            const resolveTarget = xml_helpers.resolveParent(targetFile.data, parent);
271 -
                            if (resolveEditTarget === resolveTarget) {
272 -
                                conflictingParent = parent;
273 -
                                target = parents[parent];
274 -
                                break;
275 -
                            }
276 -
                        }
277 -
                    }
278 -
                } else {
279 -
                    conflictingParent = editchange.target;
280 -
                }
281 250
282 -
                if (target && target.length !== 0) {
283 -
                    // conflict has been found
284 -
                    const witness = target[0];
285 -
                    const conflictMunge = witness.id === 'config.xml' ? configConflicts : pluginConflicts;
286 -
                    mungeutil.deep_add(conflictMunge, editchange.file, conflictingParent, witness);
287 -
                }
288 -
            }
251 +
        const registerConflict = (file, selector) => {
252 +
            const witness = files[file].parents[selector][0];
253 +
            const conflictMunge = witness.id === 'config.xml' ? configConflicts : pluginConflicts;
254 +
            mungeutil.deep_add(conflictMunge, file, selector, witness);
255 +
        };
256 +
257 +
        editchanges.forEach(({ file, target }) => {
258 +
            if (!files[file]) return;
259 +
            const { parents: changesBySelector } = files[file];
260 +
261 +
            const conflicts = changesBySelector[target] || [];
262 +
            if (conflicts.length > 0) return registerConflict(file, target);
263 +
264 +
            const targetFile = this.config_keeper.get(this.project_dir, this.platform, file);
265 +
266 +
            // For non-XML files (e.g. plist), the selector in editchange.target uniquely identifies its target.
267 +
            // Thus we already know that we have no conflict if we are not dealing with an XML file here.
268 +
            if (targetFile.type !== 'xml') return;
269 +
270 +
            // For XML files, the selector does NOT uniquely identify its target. So we resolve editchange.target
271 +
            // and any existing selectors to their matched elements and compare those for equality.
272 +
            const resolveEditTarget = xml_helpers.resolveParent(targetFile.data, target);
273 +
            if (!resolveEditTarget) return;
274 +
275 +
            const selector = Object.keys(changesBySelector).find(parent =>
276 +
                resolveEditTarget === xml_helpers.resolveParent(targetFile.data, parent)
277 +
            );
278 +
            if (selector) return registerConflict(file, selector);
289 279
        });
290 280
291 281
        return {
Files Coverage
src 89.14%
cordova-common.js 0.00%
Project Totals (20 files) 87.80%
Notifications are pending CI completion. Periodically Codecov will check the CI state, when complete notifications will be submitted. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading