aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Git
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-10 14:30:00 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-09-10 14:30:00 +0300
commit9e4a2eb24ad1882cee1cc9d43f0af0faff2ba861 (patch)
tree553b88553729097418a697c628b8b8046e34cdd9 /Software/Visual_Studio/Tango.Git
parent8e0ac4d5d4f097753321d64d3ca2d47b2f6b3770 (diff)
downloadTango-9e4a2eb24ad1882cee1cc9d43f0af0faff2ba861.tar.gz
Tango-9e4a2eb24ad1882cee1cc9d43f0af0faff2ba861.zip
Working on Tango.Git and Tag creation upon release.
Diffstat (limited to 'Software/Visual_Studio/Tango.Git')
-rw-r--r--Software/Visual_Studio/Tango.Git/GitCommit.cs13
-rw-r--r--Software/Visual_Studio/Tango.Git/GitFile.cs14
-rw-r--r--Software/Visual_Studio/Tango.Git/GitFileState.cs14
-rw-r--r--Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs132
-rw-r--r--Software/Visual_Studio/Tango.Git/Properties/AssemblyInfo.cs36
-rw-r--r--Software/Visual_Studio/Tango.Git/Tango.Git.csproj72
-rw-r--r--Software/Visual_Studio/Tango.Git/packages.config5
7 files changed, 286 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Git/GitCommit.cs b/Software/Visual_Studio/Tango.Git/GitCommit.cs
new file mode 100644
index 000000000..fc388176b
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/GitCommit.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Git
+{
+ public class GitCommit
+ {
+ public String Message { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Git/GitFile.cs b/Software/Visual_Studio/Tango.Git/GitFile.cs
new file mode 100644
index 000000000..899fa839e
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/GitFile.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Git
+{
+ public class GitFile
+ {
+ public String File { get; set; }
+ public GitFileState State { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Git/GitFileState.cs b/Software/Visual_Studio/Tango.Git/GitFileState.cs
new file mode 100644
index 000000000..4c8bb6c14
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/GitFileState.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Git
+{
+ public enum GitFileState
+ {
+ Added,
+ Modified
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs b/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs
new file mode 100644
index 000000000..e7fdf8e32
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/GitRepositoryManager.cs
@@ -0,0 +1,132 @@
+using LibGit2Sharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+
+namespace Tango.Git
+{
+ public class GitRepositoryManager : IDisposable
+ {
+ private Repository _repo;
+ private String _pat;
+ private String _userEmail;
+
+ public event EventHandler<TangoProgressChangedEventArgs<double>> Progress;
+
+ public GitRepositoryManager(String localFolder, String userEmail, String personalAccessToken)
+ {
+ _pat = personalAccessToken;
+ _userEmail = userEmail;
+ _repo = new Repository(localFolder);
+ }
+
+ public void CreatePushTag(String name, String description, String userName)
+ {
+ var tag = _repo.ApplyTag(name, new Signature(userName, _userEmail, DateTime.Now), description);
+
+ _repo.Network.Push(_repo.Network.Remotes.First(), tag.CanonicalName, new PushOptions()
+ {
+ CredentialsProvider = new LibGit2Sharp.Handlers.CredentialsHandler(CredentialsHandlerMethod),
+ OnPushTransferProgress = new LibGit2Sharp.Handlers.PushTransferProgressHandler(PushTagProgressHandlerMethod)
+ });
+ }
+
+ private bool PushTagProgressHandlerMethod(int current, int total, long bytes)
+ {
+ //TODO: Implement via TangoProgress & event...
+ RaiseProgress("Pushing Tag...", false, 0, total);
+ return true;
+ }
+
+ public List<GitCommit> GetOutgoingCommits(String branchName = "master")
+ {
+ List<GitCommit> commits = new List<GitCommit>();
+
+ var branch = _repo.Branches.FirstOrDefault(x => x.FriendlyName == branchName);
+
+ if (branch.TrackingDetails.AheadBy != null)
+ {
+ foreach (var commit in _repo.Commits.Take(branch.TrackingDetails.AheadBy.Value))
+ {
+ commits.Add(new GitCommit()
+ {
+ Message = commit.Message
+ });
+ }
+ }
+
+ return commits;
+ }
+
+ public List<GitCommit> GetIncomingCommits()
+ {
+ List<GitCommit> commits = new List<GitCommit>();
+
+ var trackingBranch = _repo.Head.TrackedBranch;
+ var log = _repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = trackingBranch.Tip.Id, ExcludeReachableFrom = _repo.Head.Tip.Id });
+
+ var count = log.Count();
+
+ foreach (var commit in log)
+ {
+ commits.Add(new GitCommit()
+ {
+ Message = commit.Message
+ });
+ }
+
+ return commits;
+ }
+
+ public List<GitFile> GetChanges()
+ {
+ List<GitFile> files = new List<GitFile>();
+
+ var status = _repo.RetrieveStatus();
+
+ foreach (var file in status.Added)
+ {
+ files.Add(new GitFile()
+ {
+ File = file.FilePath,
+ State = GitFileState.Added
+ });
+ }
+
+ foreach (var file in status.Modified)
+ {
+ files.Add(new GitFile()
+ {
+ File = file.FilePath,
+ State = GitFileState.Modified
+ });
+ }
+
+ return files;
+ }
+
+ private Credentials CredentialsHandlerMethod(string url, string usernameFromUrl, SupportedCredentialTypes types)
+ {
+ return new UsernamePasswordCredentials { Username = _userEmail, Password = _pat };
+ }
+
+ protected virtual void RaiseProgress(String message, bool isIndeterminate = true, double value = 0, double maximum = 100)
+ {
+ Progress?.Invoke(this, new TangoProgressChangedEventArgs<double>(new TangoProgress<double>()
+ {
+ IsIndeterminate = isIndeterminate,
+ Message = message,
+ Value = value,
+ Maximum = maximum
+ }));
+ }
+
+ public void Dispose()
+ {
+ _repo.Dispose();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Git/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.Git/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..4e07415b3
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tango.Git")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tango.Git")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("99081c0e-065c-4d68-bf60-f82330cca02d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Software/Visual_Studio/Tango.Git/Tango.Git.csproj b/Software/Visual_Studio/Tango.Git/Tango.Git.csproj
new file mode 100644
index 000000000..8bbf79eea
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/Tango.Git.csproj
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\packages\LibGit2Sharp.NativeBinaries.2.0.306\build\net46\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.2.0.306\build\net46\LibGit2Sharp.NativeBinaries.props')" />
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{99081C0E-065C-4D68-BF60-F82330CCA02D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tango.Git</RootNamespace>
+ <AssemblyName>Tango.Git</AssemblyName>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <Deterministic>true</Deterministic>
+ <NuGetPackageImportStamp>
+ </NuGetPackageImportStamp>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
+ <HintPath>..\packages\LibGit2Sharp.0.26.2\lib\net46\LibGit2Sharp.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="GitCommit.cs" />
+ <Compile Include="GitFileState.cs" />
+ <Compile Include="GitRepositoryManager.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="GitFile.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Tango.Core\Tango.Core.csproj">
+ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
+ <Name>Tango.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+ </PropertyGroup>
+ <Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.2.0.306\build\net46\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.2.0.306\build\net46\LibGit2Sharp.NativeBinaries.props'))" />
+ </Target>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Tango.Git/packages.config b/Software/Visual_Studio/Tango.Git/packages.config
new file mode 100644
index 000000000..576f27245
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Git/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="LibGit2Sharp" version="0.26.2" targetFramework="net461" />
+ <package id="LibGit2Sharp.NativeBinaries" version="2.0.306" targetFramework="net461" />
+</packages> \ No newline at end of file