Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加上更多 Git 命令 #55

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/OTAManager Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.2.x
3.1.x
5.0.x
6.0.x

- name: Build with dotnet
run: dotnet build app\OTAManager\OTAManager.sln --configuration Release

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.2.x
3.1.x
5.0.x
6.0.x

- name: Build with dotnet
run: dotnet build package\Lindexi.Package.sln --configuration Release

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.2.x
3.1.x
5.0.x
6.0.x

- name: Install dotnetCampus.EncodingNormalior
run: dotnet tool update -g dotnetCampus.EncodingNormalior
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/nuget-tag-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.2.x
3.1.x
5.0.x
6.0.x

- name: Install dotnet tool
run: dotnet tool install -g dotnetCampus.TagToVersion

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2021 lindexi, All Rights Reserved.</Copyright>
<Copyright>Copyright © 2022 lindexi, All Rights Reserved.</Copyright>
</PropertyGroup>

<ItemGroup>
Expand Down
23 changes: 23 additions & 0 deletions package/GitCommand/GitCommand.Tests/GitCommand.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
<PackageReference Include="Moq" Version="4.14.6" />
<PackageReference Include="MSTestEnhancer" Version="2.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GitCommand\GitCommand.csproj" />
</ItemGroup>

</Project>
80 changes: 80 additions & 0 deletions package/GitCommand/GitCommand.Tests/GitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System.IO;
using System.Threading;

using Lindexi.Src.GitCommand;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using MSTest.Extensions.Contracts;

namespace GitCommand.Tests
{
[TestClass]
public class GitTest
{
[ContractTestCase]
public void GetCurrentBranch()
{
"获取当前的分支,可以获取到分支名".Test(() =>
{
var git = new Git(new DirectoryInfo("."));
var currentBranch = git.GetCurrentBranch();
Assert.IsNotNull(currentBranch);
Assert.AreEqual(false, currentBranch.Contains('\n'));
});
}

#if DEBUG
[ContractTestCase] // 这条有负面效果,不要加入到通用测试里面
#endif
public void Push()
{
"推送给定仓库,可以推送成功".Test(() =>
{
var git = new Git(new DirectoryInfo("."));
git.Push("origin", "master");
});
}

[ContractTestCase]
public void GetCurrentCommit()
{
"尝试获取当前的 commit 字符串,可以获取成功".Test(() =>
{
var git = new Git(new DirectoryInfo("."));
var currentCommit = git.GetCurrentCommit();
Assert.IsNotNull(currentCommit);
Assert.AreEqual(false, currentCommit.Contains('\n'));
});
}

[ContractTestCase]
public void GetGitCommitRevisionCount()
{
"获取当前的 git 的 commit 数量,可以获取成功".Test(() =>
{
var git = new Git(new DirectoryInfo("."));
var count = git.GetGitCommitRevisionCount();
Assert.AreNotEqual(0, count);
});
}

[ContractTestCase]
public void GetLogCommit()
{
"获取两个 commit 之间经过的 commit 数量,可以获取成功".Test(() =>
{
var git = new Git(new DirectoryInfo("."));
var commitList = git.GetLogCommit("db25427", "13ca951bb9036999db404991b2ce4c");
Assert.AreEqual(12, commitList.Length);
});

"获取当前的历史提交记录,可以获取成功".Test(() =>
{
var git = new Git(new DirectoryInfo("."));
var commitList = git.GetLogCommit();
Assert.AreEqual(true, commitList.Length > 0);
});
}
}
}
Loading
Loading