diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-11-26 05:58:11 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-11-26 05:58:11 +0200 |
| commit | ebe229368ce63bf5a2522fb9b6b3dd248daedc9f (patch) | |
| tree | 6865868dcc29790ece43ece44dba15ee4fdc1c24 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish | |
| parent | b330818812cdfbcbfb9e85380e5cc9e392473d94 (diff) | |
| download | Tango-ebe229368ce63bf5a2522fb9b6b3dd248daedc9f.tar.gz Tango-ebe229368ce63bf5a2522fb9b6b3dd248daedc9f.zip | |
Machine_Studio_v4.2.4
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish')
2 files changed, 56 insertions, 34 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs index b8e82cc2b..25c81fcf4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/MachineStudioPublisher.cs @@ -165,40 +165,6 @@ namespace Tango.MachineStudio.Common.Publish throw new InvalidOperationException($"The local version '{local_version}' is not greater than the remote version '{remote_version}'."); } - if (Options.CreateTag) - { - String repoPath = Path.GetFullPath("../../../../../"); - using (GitRepositoryManager git = new GitRepositoryManager(repoPath, Options.Email, Options.PersonalAccessToken)) - { - OnPublishProgress(0, 100, "Checking repository changes..."); - int changes = git.GetChanges().Count; - if (changes > 0) - { - throw new InvalidOperationException($"There are {changes} uncommitted changes on the repository. Please commit and push all changes before creating the Tag"); - } - - OnPublishProgress(0, 100, "Checking outgoing commits..."); - int commits = git.GetOutgoingCommits().Count; - if (commits > 0) - { - throw new InvalidOperationException($"There are {commits} outgoing commits on the repository. Please push all commits before creating the Tag"); - } - - String tagVersion = System.Version.Parse(GetLocalVersion()).ToString(3); - String tagName = $"Machine_Studio_v{tagVersion}"; - String tagDescription = $"Snapshot of Machine Studio v{tagVersion}"; - - git.Progress += (x, e) => - { - OnPublishProgress(e.Progress.Value, e.Progress.Maximum, $"Pushing Tag '{tagName}'..."); - }; - - OnPublishProgress(0, 100, $"Creating Tag '{tagName}'..."); - - git.CreatePushTag(tagName, tagDescription, "Roy Ben Shabat"); - } - } - OnPublishProgress(0, 100, $"Requesting version upload..."); var response = _client.UploadVersion(new UploadVersionRequest() @@ -290,6 +256,55 @@ namespace Tango.MachineStudio.Common.Publish throw new InvalidOperationException("The remote version does not seems to have been updated."); } + if (Options.CreateTag) + { + String repoPath = Path.GetFullPath("../../../../../"); + String tagVersion = System.Version.Parse(GetLocalVersion()).ToString(3); + String tagName = $"Machine_Studio_v{tagVersion}"; + + using (GitRepositoryManager git = new GitRepositoryManager(repoPath, Options.Email, Options.PersonalAccessToken)) + { + OnPublishProgress(0, 100, "Checking repository changes..."); + int changes = git.GetChanges().Count; + if (changes > 0) + { + if (Options.AutoCommitAndPush) + { + OnPublishProgress(0, 100, "Committing repository changes..."); + git.Commit(tagName); + } + else + { + throw new InvalidOperationException($"There are {changes} uncommitted changes on the repository. Please commit and push all changes before creating the Tag"); + } + } + + OnPublishProgress(0, 100, "Checking outgoing commits..."); + int commits = git.GetOutgoingCommits().Count; + if (commits > 0) + { + if (Options.AutoCommitAndPush) + { + OnPublishProgress(0, 100, "Pushing repository changes..."); + git.Push(); + } + else + { + throw new InvalidOperationException($"There are {commits} outgoing commits on the repository. Please push all commits before creating the Tag"); + } + } + + git.Progress += (x, e) => + { + OnPublishProgress(e.Progress.Value, e.Progress.Maximum, $"Pushing Tag '{tagName}'..."); + }; + + OnPublishProgress(0, 100, $"Creating Tag '{tagName}'..."); + + git.CreatePushTag(tagName, Options.Comments, "Roy Ben Shabat"); + } + } + OnPublishProgress(0, 0, "Version published successfully."); } catch (Exception ex) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs index 80ca01149..c0983eb8b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Publish/PublishOptions.cs @@ -95,6 +95,13 @@ namespace Tango.MachineStudio.Common.Publish set { _createTag = value; RaisePropertyChangedAuto(); } } + private bool _autoCommitAndSync; + public bool AutoCommitAndPush + { + get { return _autoCommitAndSync; } + set { _autoCommitAndSync = value; RaisePropertyChangedAuto(); } + } + public PublishOptions() { BasePath = AppDomain.CurrentDomain.BaseDirectory + "..\\"; |
