|
1 |
| -using Nuke.Common; |
2 |
| -using Nuke.Common.Git; |
3 |
| - |
4 |
| -namespace ricaun.Nuke.Components |
5 |
| -{ |
6 |
| - /// <summary> |
7 |
| - /// IHazGitRepository |
8 |
| - /// </summary> |
9 |
| - public interface IHazGitRepository : INukeBuild |
10 |
| - { |
11 |
| - /// <summary> |
12 |
| - /// GitHubToken |
13 |
| - /// </summary> |
14 |
| - [Secret][Parameter] public string GitHubToken => TryGetValue(() => GitHubToken); |
15 |
| - |
16 |
| - /// <summary> |
17 |
| - /// GitRepository |
18 |
| - /// </summary> |
19 |
| - [GitRepository] GitRepository GitRepository => TryGetValue(() => GitRepository); |
20 |
| - |
21 |
| - /// <summary> |
22 |
| - /// GetGitRepositoryPackageUrl (default: https://nuget.pkg.github.com/repository_owner/index.json) |
23 |
| - /// </summary> |
24 |
| - /// <returns></returns> |
25 |
| - public string GetGitRepositoryPackageUrl() |
26 |
| - { |
27 |
| - if (GitRepository == null) |
28 |
| - { |
29 |
| - Serilog.Log.Warning($"GitRepository not found."); |
30 |
| - return ""; |
31 |
| - } |
32 |
| - return $@"https://nuget.pkg.github.com/{GetGitRepositoryOwner()}/index.json"; |
33 |
| - } |
34 |
| - |
35 |
| - /// <summary> |
36 |
| - /// GetGitRepositoryOwner based on the GitRepository.Identifier |
37 |
| - /// </summary> |
38 |
| - /// <returns></returns> |
39 |
| - public string GetGitRepositoryOwner() |
40 |
| - { |
41 |
| - if (GitRepository == null) return ""; |
42 |
| - return GitRepository.Identifier?.Split("/")[0]; |
43 |
| - } |
44 |
| - } |
45 |
| -} |
| 1 | +using Nuke.Common; |
| 2 | +using Nuke.Common.Git; |
| 3 | +using ricaun.Nuke.Extensions; |
| 4 | + |
| 5 | +namespace ricaun.Nuke.Components |
| 6 | +{ |
| 7 | + /// <summary> |
| 8 | + /// IHazGitRepository |
| 9 | + /// </summary> |
| 10 | + public interface IHazGitRepository : INukeBuild |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// GitHubToken |
| 14 | + /// </summary> |
| 15 | + [Secret][Parameter] public string GitHubToken => TryGetValue(() => GitHubToken); |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// GitRepository |
| 19 | + /// </summary> |
| 20 | + [GitRepository] GitRepository GitRepository => TryGetValue(() => GitRepository); |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// GetGitRepositoryPackageUrl (default: https://nuget.pkg.github.com/repository_owner/index.json) |
| 24 | + /// </summary> |
| 25 | + /// <returns></returns> |
| 26 | + public string GetGitRepositoryPackageUrl() |
| 27 | + { |
| 28 | + if (GitRepository == null) |
| 29 | + { |
| 30 | + Serilog.Log.Warning($"GitRepository not found."); |
| 31 | + return ""; |
| 32 | + } |
| 33 | + return $@"https://nuget.pkg.github.com/{GetGitRepositoryOwner()}/index.json"; |
| 34 | + } |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// GetGitRepositoryOwner based on the GitRepository.Identifier |
| 38 | + /// </summary> |
| 39 | + /// <returns></returns> |
| 40 | + public string GetGitRepositoryOwner() |
| 41 | + { |
| 42 | + if (GitRepository == null) return ""; |
| 43 | + return GitRepository.Identifier?.Split("/")[0]; |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Indicates whether the forked repository is enabled. |
| 48 | + /// </summary> |
| 49 | + [Parameter] |
| 50 | + bool EnableForkedRepository => TryGetValue<bool?>(() => EnableForkedRepository) ?? false; |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Determines if the forked repository should be skipped. |
| 54 | + /// </summary> |
| 55 | + /// <returns>True if the forked repository should be skipped; otherwise, false.</returns> |
| 56 | + public bool SkipForked() |
| 57 | + { |
| 58 | + if (EnableForkedRepository) |
| 59 | + return false; |
| 60 | + |
| 61 | + return IsGitRepositoryForked(); |
| 62 | + } |
| 63 | + /// <summary> |
| 64 | + /// IsGitRepositoryForked |
| 65 | + /// </summary> |
| 66 | + /// <returns></returns> |
| 67 | + public bool IsGitRepositoryForked() |
| 68 | + { |
| 69 | + return GitRepository.IsForked(); |
| 70 | + } |
| 71 | + } |
| 72 | +} |
|
0 commit comments