add a changeset tag if a merge conflict occurred (#9636)

This commit is contained in:
Kyℓe Hensel
2025-03-05 22:38:32 +11:00
committed by GitHub
parent c7e177fee4
commit 7beace6698
4 changed files with 52 additions and 2 deletions
+16 -2
View File
@@ -11,6 +11,7 @@ import { t } from '../core/localizer';
import { utilArrayUnion, utilArrayUniq, utilDisplayName, utilDisplayType, utilRebind } from '../util';
/** @param {iD.Context} context */
export function coreUploader(context) {
var dispatch = d3_dispatch(
@@ -30,6 +31,7 @@ export function coreUploader(context) {
var _isSaving = false;
let _anyConflictsAutomaticallyResolved = false;
var _conflicts = [];
var _errors = [];
var _origChanges;
@@ -72,6 +74,7 @@ export function coreUploader(context) {
var history = context.history();
_anyConflictsAutomaticallyResolved = false;
_conflicts = [];
_errors = [];
@@ -251,7 +254,10 @@ export function coreUploader(context) {
history.replace(merge);
var mergeConflicts = merge.conflicts();
if (!mergeConflicts.length) return; // merged safely
if (!mergeConflicts.length) {
_anyConflictsAutomaticallyResolved = true;
return; // merged safely
}
var forceLocal = actionMergeRemoteChanges(id, localGraph, remoteGraph, _discardTags).withOption('force_local');
var forceRemote = actionMergeRemoteChanges(id, localGraph, remoteGraph, _discardTags).withOption('force_remote');
@@ -273,7 +279,7 @@ export function coreUploader(context) {
}
function upload(changeset) {
async function upload(changeset) {
var osm = context.connection();
if (!osm) {
_errors.push({ msg: 'No OSM Service' });
@@ -286,6 +292,11 @@ export function coreUploader(context) {
didResultInErrors();
} else {
if (_anyConflictsAutomaticallyResolved) {
// add a changeset tag to aid reviewers
changeset.tags.merge_conflict_resolved = 'automatically';
await osm.updateChangesetTags(changeset);
}
var history = context.history();
var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
if (changes.modified.length || changes.created.length || changes.deleted.length) {
@@ -339,6 +350,9 @@ export function coreUploader(context) {
function didResultInConflicts(changeset) {
// add a changeset tag to aid reviewers
changeset.tags.merge_conflict_resolved = 'manually';
context.connection().updateChangesetTags(changeset);
_conflicts.sort(function(a, b) { return b.id.localeCompare(a.id); });
+10
View File
@@ -876,6 +876,16 @@ export default {
}
},
/** updates the tags on an existing unclosed changeset */
// PUT /api/0.6/changeset/#id
updateChangesetTags: (changeset) => {
return oauth.fetch(`${oauth.options().apiUrl}/api/0.6/changeset/${changeset.id}`, {
method: 'PUT',
headers: { 'Content-Type': 'text/xml' },
body: JXON.stringify(changeset.asJXON())
});
},
// Load multiple users in chunks
// (note: callback may be called multiple times)