-
Notifications
You must be signed in to change notification settings - Fork 892
/
Copy pathRepositoryInformation.cs
86 lines (73 loc) · 2.69 KB
/
RepositoryInformation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Provides high level information about a repository.
/// </summary>
public class RepositoryInformation
{
private readonly Repository repo;
/// <summary>
/// Needed for mocking purposes.
/// </summary>
protected RepositoryInformation()
{ }
internal RepositoryInformation(Repository repo, bool isBare)
{
this.repo = repo;
IsBare = isBare;
FilePath path = Proxy.git_repository_path(repo.Handle);
FilePath workingDirectoryPath = Proxy.git_repository_workdir(repo.Handle);
Path = path == null ? null : path.Native;
WorkingDirectory = workingDirectoryPath == null ? null : workingDirectoryPath.Native;
IsShallow = Proxy.git_repository_is_shallow(repo.Handle);
}
/// <summary>
/// Gets the normalized path to the git repository.
/// </summary>
public virtual string Path { get; private set; }
/// <summary>
/// Gets the normalized path to the working directory.
/// <para>
/// If the repository is bare, null is returned.
/// </para>
/// </summary>
public virtual string WorkingDirectory { get; private set; }
/// <summary>
/// Indicates whether the repository has a working directory.
/// </summary>
public virtual bool IsBare { get; private set; }
/// <summary>
/// Indicates whether the repository is shallow (the result of `git clone --depth ...`)
/// </summary>
public virtual bool IsShallow { get; private set; }
/// <summary>
/// Indicates whether the Head points to an arbitrary commit instead of the tip of a local branch.
/// </summary>
public virtual bool IsHeadDetached
{
get { return Proxy.git_repository_head_detached(repo.Handle); }
}
/// <summary>
/// Indicates whether the Head points to a reference which doesn't exist.
/// </summary>
public virtual bool IsHeadUnborn
{
get { return Proxy.git_repository_head_unborn(repo.Handle); }
}
/// <summary>
/// The pending interactive operation.
/// </summary>
public virtual CurrentOperation CurrentOperation
{
get { return Proxy.git_repository_state(repo.Handle); }
}
/// <summary>
/// The message for a pending interactive operation.
/// </summary>
public virtual string Message
{
get { return Proxy.git_repository_message(repo.Handle); }
}
}
}