forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepositoryInformation.cs
More file actions
62 lines (53 loc) · 2 KB
/
Copy pathRepositoryInformation.cs
File metadata and controls
62 lines (53 loc) · 2 KB
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
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Provides high level information about a repository.
/// </summary>
public class RepositoryInformation
{
private readonly Repository repo;
internal RepositoryInformation(Repository repo, bool isBare)
{
this.repo = repo;
IsBare = isBare;
FilePath path = NativeMethods.git_repository_path(repo.Handle);
FilePath workingDirectoryPath = NativeMethods.git_repository_workdir(repo.Handle);
Path = path.Native;
WorkingDirectory = workingDirectoryPath == null ? null : workingDirectoryPath.Native;
}
/// <summary>
/// Gets the normalized path to the git repository.
/// </summary>
public string Path { get; private set; }
/// <summary>
/// Gets the normalized path to the working directory.
/// <para>
/// Is the repository is bare, null is returned.
/// </para>
/// </summary>
public string WorkingDirectory { get; private set; }
/// <summary>
/// Indicates whether the repository has a working directory.
/// </summary>
public bool IsBare { get; private set; }
/// <summary>
/// Gets a value indicating whether this repository is empty.
/// </summary>
/// <value>
/// <c>true</c> if this repository is empty; otherwise, <c>false</c>.
/// </value>
public bool IsEmpty
{
get { return NativeMethods.RepositoryStateChecker(repo.Handle, NativeMethods.git_repository_is_empty); }
}
/// <summary>
/// Indicates whether the Head points to an arbitrary commit instead of the tip of a local banch.
/// </summary>
public bool IsHeadDetached
{
get { return NativeMethods.RepositoryStateChecker(repo.Handle, NativeMethods.git_repository_head_detached); }
}
}
}