Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 299097a

Browse files
committed
Fixes VSTS Bug 1003485: [Feedback] After Commit and Push changes
remains https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1003485 The commit dialog always reponses with ok when commit is clicked. ButtonCommitClicked handles that dialog but doesn't change the response. So the best solution is to let the commit dialog handle the commit logic itself.
1 parent a6bc297 commit 299097a

File tree

2 files changed

+71
-64
lines changed

2 files changed

+71
-64
lines changed

main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Dialogs/CommitDialog.cs

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ namespace MonoDevelop.VersionControl.Dialogs
4444
{
4545
partial class CommitDialog : Gtk.Dialog
4646
{
47+
Repository vc;
4748
ListStore store;
4849
HashSet<FilePath> selected = new HashSet<FilePath> ();
4950
List<CommitDialogExtension> extensions = new List<CommitDialogExtension> ();
5051
ChangeSet changeSet;
5152
string oldMessage;
5253
bool responseSensitive;
5354

54-
public CommitDialog (ChangeSet changeSet)
55+
public CommitDialog (Repository vc, ChangeSet changeSet)
5556
{
57+
this.vc = vc;
5658
Build ();
5759

5860
store = new ListStore(typeof (Xwt.Drawing.Image), typeof (string), typeof (string), typeof(bool), typeof(object));
@@ -205,12 +207,20 @@ void HandleAllowCommitChanged (object sender, EventArgs e)
205207

206208
protected override void OnResponse (Gtk.ResponseType type)
207209
{
210+
base.OnResponse (type);
211+
208212
if (type != Gtk.ResponseType.Ok) {
209213
changeSet.GlobalComment = oldMessage;
210-
} else if (!ButtonCommitClicked ())
214+
EndCommit (false);
215+
} else if (!ButtonCommitClicked ()) {
211216
return;
217+
}
212218

213-
base.OnResponse (type);
219+
if (type == Gtk.ResponseType.Ok) {
220+
VersionControlService.NotifyBeforeCommit (vc, changeSet);
221+
new CommitWorker (vc, changeSet, this).StartAsync ();
222+
return;
223+
}
214224
}
215225

216226
CancellationTokenSource destroyTokenSource = new CancellationTokenSource ();
@@ -342,5 +352,60 @@ void OnCommitToggledHandler(object o, ToggledArgs args)
342352
else
343353
selected.Remove (vinfo.LocalPath);
344354
}
355+
356+
private class CommitWorker : VersionControlTask
357+
{
358+
Repository vc;
359+
ChangeSet changeSet;
360+
CommitDialog dlg;
361+
bool success;
362+
363+
public CommitWorker (Repository vc, ChangeSet changeSet, CommitDialog dlg)
364+
{
365+
this.vc = vc;
366+
this.changeSet = changeSet;
367+
this.dlg = dlg;
368+
OperationType = VersionControlOperationType.Push;
369+
}
370+
371+
protected override string GetDescription ()
372+
{
373+
return GettextCatalog.GetString ("Committing {0}...", changeSet.BaseLocalPath);
374+
}
375+
376+
protected override async Task RunAsync ()
377+
{
378+
success = true;
379+
try {
380+
// store global comment before commit.
381+
VersionControlService.SetCommitComment (changeSet.BaseLocalPath, changeSet.GlobalComment, true);
382+
383+
await vc.CommitAsync (changeSet, Monitor);
384+
Monitor.ReportSuccess (GettextCatalog.GetString ("Commit operation completed."));
385+
386+
// Reset the global comment on successful commit.
387+
VersionControlService.SetCommitComment (changeSet.BaseLocalPath, "", true);
388+
} catch (Exception ex) {
389+
LoggingService.LogError ("Commit operation failed", ex);
390+
Monitor.ReportError (ex.Message, null);
391+
success = false;
392+
throw;
393+
}
394+
}
395+
396+
protected override void Finished ()
397+
{
398+
dlg.EndCommit (success);
399+
dlg.Destroy ();
400+
FileUpdateEventArgs args = new FileUpdateEventArgs ();
401+
foreach (ChangeSetItem it in changeSet.Items)
402+
args.Add (new FileUpdateEventInfo (vc, it.LocalPath, it.IsDirectory));
403+
404+
if (args.Count > 0)
405+
VersionControlService.NotifyFileStatusChanged (args);
406+
407+
VersionControlService.NotifyAfterCommit (vc, changeSet, success);
408+
}
409+
}
345410
}
346411
}

main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/CommitCommand.cs

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,9 @@ public static async Task CommitAsync (Repository vc, ChangeSet changeSet)
2020
VersionControlService.NotifyPrepareCommit (vc, changeSet);
2121
if (!await VerifyUnsavedChangesAsync (changeSet))
2222
return;
23-
CommitDialog dlg = new CommitDialog (changeSet);
23+
CommitDialog dlg = new CommitDialog (vc, changeSet);
2424
try {
25-
if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
26-
VersionControlService.NotifyBeforeCommit (vc, changeSet);
27-
new CommitWorker (vc, changeSet, dlg).StartAsync();
28-
return;
29-
}
30-
dlg.EndCommit (false);
25+
MessageService.RunCustomDialog (dlg);
3126
} finally {
3227
dlg.Destroy ();
3328
dlg.Dispose ();
@@ -91,59 +86,6 @@ static async Task<bool> VerifyUnsavedChangesAsync (ChangeSet changeSet)
9186
return allowCommit;
9287
}
9388

94-
private class CommitWorker : VersionControlTask
95-
{
96-
Repository vc;
97-
ChangeSet changeSet;
98-
CommitDialog dlg;
99-
bool success;
100-
101-
public CommitWorker (Repository vc, ChangeSet changeSet, CommitDialog dlg)
102-
{
103-
this.vc = vc;
104-
this.changeSet = changeSet;
105-
this.dlg = dlg;
106-
OperationType = VersionControlOperationType.Push;
107-
}
108-
109-
protected override string GetDescription()
110-
{
111-
return GettextCatalog.GetString ("Committing {0}...", changeSet.BaseLocalPath);
112-
}
113-
114-
protected override async Task RunAsync ()
115-
{
116-
success = true;
117-
try {
118-
// store global comment before commit.
119-
VersionControlService.SetCommitComment (changeSet.BaseLocalPath, changeSet.GlobalComment, true);
120-
121-
await vc.CommitAsync (changeSet, Monitor);
122-
Monitor.ReportSuccess (GettextCatalog.GetString ("Commit operation completed."));
123-
124-
// Reset the global comment on successful commit.
125-
VersionControlService.SetCommitComment (changeSet.BaseLocalPath, "", true);
126-
} catch (Exception ex) {
127-
LoggingService.LogError ("Commit operation failed", ex);
128-
Monitor.ReportError (ex.Message, null);
129-
success = false;
130-
throw;
131-
}
132-
}
133-
134-
protected override void Finished ()
135-
{
136-
dlg.EndCommit (success);
137-
dlg.Destroy ();
138-
FileUpdateEventArgs args = new FileUpdateEventArgs ();
139-
foreach (ChangeSetItem it in changeSet.Items)
140-
args.Add (new FileUpdateEventInfo (vc, it.LocalPath, it.IsDirectory));
141-
142-
if (args.Count > 0)
143-
VersionControlService.NotifyFileStatusChanged (args);
144-
145-
VersionControlService.NotifyAfterCommit (vc, changeSet, success);
146-
}
147-
}
89+
14890
}
14991
}

0 commit comments

Comments
 (0)