|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using LibGit2Sharp; |
| 4 | + |
| 5 | +namespace GitVersion |
| 6 | +{ |
| 7 | + /// <summary> |
| 8 | + /// Default implementation of <see cref="IGitRepositoryCommands"/> using |
| 9 | + /// the <c>static</c> <see cref="Commands"/> <c>class</c>. |
| 10 | + /// </summary> |
| 11 | + public class GitRepositoryCommands : IGitRepositoryCommands |
| 12 | + { |
| 13 | + private readonly Lazy<IRepository> lazyRepository; |
| 14 | + private IRepository repository => lazyRepository.Value; |
| 15 | + |
| 16 | + public GitRepositoryCommands(Lazy<IRepository> lazyRepository) |
| 17 | + { |
| 18 | + this.lazyRepository = lazyRepository ?? throw new System.ArgumentNullException(nameof(lazyRepository)); |
| 19 | + } |
| 20 | + |
| 21 | + public Branch Checkout(string committishOrBranchSpec) |
| 22 | + { |
| 23 | + return Commands.Checkout(this.repository, committishOrBranchSpec); |
| 24 | + } |
| 25 | + |
| 26 | + public Branch Checkout(string committishOrBranchSpec, CheckoutOptions options) |
| 27 | + { |
| 28 | + return Commands.Checkout(this.repository, committishOrBranchSpec, options); |
| 29 | + } |
| 30 | + |
| 31 | + public Branch Checkout(Branch branch) |
| 32 | + { |
| 33 | + return Commands.Checkout(this.repository, branch); |
| 34 | + } |
| 35 | + |
| 36 | + public Branch Checkout(Branch branch, CheckoutOptions options) |
| 37 | + { |
| 38 | + return Commands.Checkout(this.repository, branch, options); |
| 39 | + } |
| 40 | + |
| 41 | + public Branch Checkout(Commit commit) |
| 42 | + { |
| 43 | + return Commands.Checkout(this.repository, commit); |
| 44 | + } |
| 45 | + |
| 46 | + public Branch Checkout(Commit commit, CheckoutOptions options) |
| 47 | + { |
| 48 | + return Commands.Checkout(this.repository, commit, options); |
| 49 | + } |
| 50 | + |
| 51 | + public void Checkout(Tree tree, CheckoutOptions checkoutOptions, string refLogHeadSpec) |
| 52 | + { |
| 53 | + Commands.Checkout(this.repository, tree, checkoutOptions, refLogHeadSpec); |
| 54 | + } |
| 55 | + |
| 56 | + public void Fetch(string remote, IEnumerable<string> refspecs, FetchOptions options, string logMessage) |
| 57 | + { |
| 58 | + Commands.Fetch((Repository)this.repository, remote, refspecs, options, logMessage); |
| 59 | + } |
| 60 | + |
| 61 | + public void Move(string sourcePath, string destinationPath) |
| 62 | + { |
| 63 | + Commands.Move(this.repository, sourcePath, destinationPath); |
| 64 | + } |
| 65 | + |
| 66 | + public void Move(IEnumerable<string> sourcePaths, IEnumerable<string> destinationPaths) |
| 67 | + { |
| 68 | + Commands.Move(this.repository, sourcePaths, destinationPaths); |
| 69 | + } |
| 70 | + |
| 71 | + public MergeResult Pull(Signature merger, PullOptions options) |
| 72 | + { |
| 73 | + return Commands.Pull((Repository)this.repository, merger, options); |
| 74 | + } |
| 75 | + |
| 76 | + public void Remove(string path, bool removeFromWorkingDirectory) |
| 77 | + { |
| 78 | + Commands.Remove(this.repository, path, removeFromWorkingDirectory); |
| 79 | + } |
| 80 | + |
| 81 | + public void Remove(IEnumerable<string> paths) |
| 82 | + { |
| 83 | + Commands.Remove(this.repository, paths); |
| 84 | + } |
| 85 | + |
| 86 | + public void Remove(IEnumerable<string> paths, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions) |
| 87 | + { |
| 88 | + Commands.Remove(this.repository, paths, removeFromWorkingDirectory, explicitPathsOptions); |
| 89 | + } |
| 90 | + |
| 91 | + public void Remove(string path) |
| 92 | + { |
| 93 | + Commands.Remove(this.repository, path); |
| 94 | + } |
| 95 | + |
| 96 | + public void Remove(string path, bool removeFromWorkingDirectory, ExplicitPathsOptions explicitPathsOptions) |
| 97 | + { |
| 98 | + Commands.Remove(this.repository, path, removeFromWorkingDirectory, explicitPathsOptions); |
| 99 | + } |
| 100 | + |
| 101 | + public void Stage(string path) |
| 102 | + { |
| 103 | + Commands.Stage(this.repository, path); |
| 104 | + } |
| 105 | + |
| 106 | + public void Stage(string path, StageOptions stageOptions) |
| 107 | + { |
| 108 | + Commands.Stage(this.repository, path, stageOptions); |
| 109 | + } |
| 110 | + |
| 111 | + public void Stage(IEnumerable<string> paths) |
| 112 | + { |
| 113 | + Commands.Stage(this.repository, paths); |
| 114 | + } |
| 115 | + |
| 116 | + public void Stage(IEnumerable<string> paths, StageOptions stageOptions) |
| 117 | + { |
| 118 | + Commands.Stage(this.repository, paths, stageOptions); |
| 119 | + } |
| 120 | + |
| 121 | + public void Unstage(string path) |
| 122 | + { |
| 123 | + Commands.Unstage(this.repository, path); |
| 124 | + } |
| 125 | + |
| 126 | + public void Unstage(string path, ExplicitPathsOptions explicitPathsOptions) |
| 127 | + { |
| 128 | + Commands.Unstage(this.repository, path, explicitPathsOptions); |
| 129 | + } |
| 130 | + |
| 131 | + public void Unstage(IEnumerable<string> paths) |
| 132 | + { |
| 133 | + Commands.Unstage(this.repository, paths); |
| 134 | + } |
| 135 | + |
| 136 | + public void Unstage(IEnumerable<string> paths, ExplicitPathsOptions explicitPathsOptions) |
| 137 | + { |
| 138 | + Commands.Unstage(this.repository, paths, explicitPathsOptions); |
| 139 | + } |
| 140 | + } |
| 141 | +} |
0 commit comments