本文整理汇总了C#中Repository.GetConfig方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetConfig方法的具体用法?C# Repository.GetConfig怎么用?C# Repository.GetConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.GetConfig方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Of
/// <summary>
/// Compute the tracking status for the <code>branchName</code> in
/// <code>repository</code>.
/// </summary>
/// <remarks>
/// Compute the tracking status for the <code>branchName</code> in
/// <code>repository</code>.
/// </remarks>
/// <param name="repository">the git repository to compute the status from</param>
/// <param name="branchName">the local branch</param>
/// <returns>the tracking status, or null if it is not known</returns>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public static NGit.BranchTrackingStatus Of(Repository repository, string branchName
)
{
BranchConfig branchConfig = new BranchConfig(repository.GetConfig(), branchName);
string trackingBranch = branchConfig.GetTrackingBranch();
if (trackingBranch == null)
{
return null;
}
Ref tracking = repository.GetRef(trackingBranch);
if (tracking == null)
{
return null;
}
Ref local = repository.GetRef(branchName);
if (local == null)
{
return null;
}
RevWalk walk = new RevWalk(repository);
RevCommit localCommit = walk.ParseCommit(local.GetObjectId());
RevCommit trackingCommit = walk.ParseCommit(tracking.GetObjectId());
walk.SetRevFilter(RevFilter.MERGE_BASE);
walk.MarkStart(localCommit);
walk.MarkStart(trackingCommit);
RevCommit mergeBase = walk.Next();
walk.Reset();
walk.SetRevFilter(RevFilter.ALL);
int aheadCount = RevWalkUtils.Count(walk, localCommit, mergeBase);
int behindCount = RevWalkUtils.Count(walk, trackingCommit, mergeBase);
return new NGit.BranchTrackingStatus(trackingBranch, aheadCount, behindCount);
}
示例2: SubmoduleWalk
/// <summary>Create submodule generator</summary>
/// <param name="repository"></param>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public SubmoduleWalk(Repository repository)
{
this.repository = repository;
repoConfig = repository.GetConfig();
walk = new TreeWalk(repository);
walk.Recursive = true;
}
示例3: PersonIdent
/// <summary>Creates new PersonIdent from config info in repository, with current time.
/// </summary>
/// <remarks>
/// Creates new PersonIdent from config info in repository, with current time.
/// This new PersonIdent gets the info from the default committer as available
/// from the configuration.
/// </remarks>
/// <param name="repo"></param>
public PersonIdent(Repository repo)
{
UserConfig config = repo.GetConfig().Get(UserConfig.KEY);
name = config.GetCommitterName();
emailAddress = config.GetCommitterEmail();
when = SystemReader.GetInstance().GetCurrentTime();
tzOffset = SystemReader.GetInstance().GetTimezone(when);
}
示例4: ResolveMerger
/// <param name="local"></param>
/// <param name="inCore"></param>
protected internal ResolveMerger(Repository local, bool inCore) : base(local)
{
DiffAlgorithm.SupportedAlgorithm diffAlg = local.GetConfig().GetEnum(ConfigConstants
.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_ALGORITHM, DiffAlgorithm.SupportedAlgorithm
.HISTOGRAM);
mergeAlgorithm = new MergeAlgorithm(DiffAlgorithm.GetAlgorithm(diffAlg));
commitNames = new string[] { "BASE", "OURS", "THEIRS" };
oi = GetObjectInserter();
this.inCore = inCore;
if (inCore)
{
dircache = DirCache.NewInCore();
}
}
示例5: OpenAll
/// <summary>Open new transport instances to connect two repositories.</summary>
/// <remarks>Open new transport instances to connect two repositories.</remarks>
/// <param name="local">existing local repository.</param>
/// <param name="remote">
/// location of the remote repository - may be URI or remote
/// configuration name.
/// </param>
/// <param name="op">
/// planned use of the returned Transport; the URI may differ
/// based on the type of connection desired.
/// </param>
/// <returns>
/// the list of new transport instances for every URI in remote
/// configuration.
/// </returns>
/// <exception cref="Sharpen.URISyntaxException">
/// the location is not a remote defined in the configuration
/// file and is not a well-formed URL.
/// </exception>
/// <exception cref="System.NotSupportedException">the protocol specified is not supported.
/// </exception>
/// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
/// </exception>
public static IList<NGit.Transport.Transport> OpenAll(Repository local, string remote
, Transport.Operation op)
{
RemoteConfig cfg = new RemoteConfig(local.GetConfig(), remote);
if (DoesNotExist(cfg))
{
AList<NGit.Transport.Transport> transports = new AList<NGit.Transport.Transport>(
1);
transports.AddItem(Open(local, new URIish(remote), null));
return transports;
}
return OpenAll(local, cfg, op);
}
示例6: Open
/// <summary>Open a new transport instance to connect two repositories.</summary>
/// <remarks>Open a new transport instance to connect two repositories.</remarks>
/// <param name="local">existing local repository.</param>
/// <param name="remote">
/// location of the remote repository - may be URI or remote
/// configuration name.
/// </param>
/// <param name="op">
/// planned use of the returned Transport; the URI may differ
/// based on the type of connection desired.
/// </param>
/// <returns>
/// the new transport instance. Never null. In case of multiple URIs
/// in remote configuration, only the first is chosen.
/// </returns>
/// <exception cref="Sharpen.URISyntaxException">
/// the location is not a remote defined in the configuration
/// file and is not a well-formed URL.
/// </exception>
/// <exception cref="System.NotSupportedException">the protocol specified is not supported.
/// </exception>
/// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
/// </exception>
public static NGit.Transport.Transport Open(Repository local, string remote, Transport.Operation
op)
{
RemoteConfig cfg = new RemoteConfig(local.GetConfig(), remote);
if (DoesNotExist(cfg))
{
return Open(local, new URIish(remote), null);
}
return Open(local, cfg, op);
}
示例7: Transport
/// <summary>Create a new transport instance.</summary>
/// <remarks>Create a new transport instance.</remarks>
/// <param name="local">
/// the repository this instance will fetch into, or push out of.
/// This must be the repository passed to
/// <see cref="Open(NGit.Repository, URIish)">Open(NGit.Repository, URIish)</see>
/// .
/// </param>
/// <param name="uri">
/// the URI used to access the remote repository. This must be the
/// URI passed to
/// <see cref="Open(NGit.Repository, URIish)">Open(NGit.Repository, URIish)</see>
/// .
/// </param>
protected internal Transport(Repository local, URIish uri)
{
TransferConfig tc = local.GetConfig().Get(TransferConfig.KEY);
this.local = local;
this.uri = uri;
this.checkFetchedObjects = tc.IsFsckObjects();
this.credentialsProvider = CredentialsProvider.GetDefault();
}
示例8: FileTreeIterator
/// <summary>Create a new iterator to traverse the work tree and its children.</summary>
/// <remarks>Create a new iterator to traverse the work tree and its children.</remarks>
/// <param name="repo">the repository whose working tree will be scanned.</param>
public FileTreeIterator(Repository repo) : this(repo.WorkTree, repo.FileSystem, repo
.GetConfig().Get(WorkingTreeOptions.KEY))
{
InitRootIterator(repo);
}
示例9: GetSubmoduleRemoteUrl
/// <summary>Resolve submodule repository URL.</summary>
/// <remarks>
/// Resolve submodule repository URL.
/// <p>
/// This handles relative URLs that are typically specified in the
/// '.gitmodules' file by resolving them against the remote URL of the parent
/// repository.
/// <p>
/// Relative URLs will be resolved against the parent repository's working
/// directory if the parent repository has no configured remote URL.
/// </remarks>
/// <param name="parent">parent repository</param>
/// <param name="url">absolute or relative URL of the submodule repository</param>
/// <returns>resolved URL</returns>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public static string GetSubmoduleRemoteUrl(Repository parent, string url)
{
if (!url.StartsWith("./") && !url.StartsWith("../"))
{
return url;
}
string remoteName = null;
// Look up remote URL associated wit HEAD ref
Ref @ref = parent.GetRef(Constants.HEAD);
if (@ref != null)
{
if (@ref.IsSymbolic())
{
@ref = @ref.GetLeaf();
}
remoteName = parent.GetConfig().GetString(ConfigConstants.CONFIG_BRANCH_SECTION,
Repository.ShortenRefName(@ref.GetName()), ConfigConstants.CONFIG_KEY_REMOTE);
}
// Fall back to 'origin' if current HEAD ref has no remote URL
if (remoteName == null)
{
remoteName = Constants.DEFAULT_REMOTE_NAME;
}
string remoteUrl = parent.GetConfig().GetString(ConfigConstants.CONFIG_REMOTE_SECTION
, remoteName, ConfigConstants.CONFIG_KEY_URL);
// Fall back to parent repository's working directory if no remote URL
if (remoteUrl == null)
{
remoteUrl = parent.WorkTree.GetAbsolutePath();
// Normalize slashes to '/'
if ('\\' == FilePath.separatorChar)
{
remoteUrl = remoteUrl.Replace('\\', '/');
}
}
// Remove trailing '/'
if (remoteUrl[remoteUrl.Length - 1] == '/')
{
remoteUrl = Sharpen.Runtime.Substring(remoteUrl, 0, remoteUrl.Length - 1);
}
char separator = '/';
string submoduleUrl = url;
while (submoduleUrl.Length > 0)
{
if (submoduleUrl.StartsWith("./"))
{
submoduleUrl = Sharpen.Runtime.Substring(submoduleUrl, 2);
}
else
{
if (submoduleUrl.StartsWith("../"))
{
int lastSeparator = remoteUrl.LastIndexOf('/');
if (lastSeparator < 1)
{
lastSeparator = remoteUrl.LastIndexOf(':');
separator = ':';
}
if (lastSeparator < 1)
{
throw new IOException(MessageFormat.Format(JGitText.Get().submoduleParentRemoteUrlInvalid
, remoteUrl));
}
remoteUrl = Sharpen.Runtime.Substring(remoteUrl, 0, lastSeparator);
submoduleUrl = Sharpen.Runtime.Substring(submoduleUrl, 3);
}
else
{
break;
}
}
}
return remoteUrl + separator + submoduleUrl;
}
示例10: CheckoutEntry
/// <summary>
/// Updates the file in the working tree with content and mode from an entry
/// in the index.
/// </summary>
/// <remarks>
/// Updates the file in the working tree with content and mode from an entry
/// in the index. The new content is first written to a new temporary file in
/// the same directory as the real file. Then that new file is renamed to the
/// final filename.
/// <p>
/// TODO: this method works directly on File IO, we may need another
/// abstraction (like WorkingTreeIterator). This way we could tell e.g.
/// Eclipse that Files in the workspace got changed
/// </p>
/// </remarks>
/// <param name="repo"></param>
/// <param name="f">
/// the file to be modified. The parent directory for this file
/// has to exist already
/// </param>
/// <param name="entry">the entry containing new mode and content</param>
/// <param name="or">object reader to use for checkout</param>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public static void CheckoutEntry(Repository repo, FilePath f, DirCacheEntry entry
, ObjectReader or)
{
ObjectLoader ol = or.Open(entry.GetObjectId());
FilePath parentDir = f.GetParentFile();
FilePath tmpFile = FilePath.CreateTempFile("._" + f.GetName(), null, parentDir);
WorkingTreeOptions opt = repo.GetConfig().Get(WorkingTreeOptions.KEY);
FileOutputStream rawChannel = new FileOutputStream(tmpFile);
OutputStream channel;
if (opt.GetAutoCRLF() == CoreConfig.AutoCRLF.TRUE)
{
channel = new AutoCRLFOutputStream(rawChannel);
}
else
{
channel = rawChannel;
}
try
{
ol.CopyTo(channel);
}
finally
{
channel.Close();
}
FS fs = repo.FileSystem;
if (opt.IsFileMode() && fs.SupportsExecute())
{
if (FileMode.EXECUTABLE_FILE.Equals(entry.RawMode))
{
if (!fs.CanExecute(tmpFile))
{
fs.SetExecute(tmpFile, true);
}
}
else
{
if (fs.CanExecute(tmpFile))
{
fs.SetExecute(tmpFile, false);
}
}
}
if (!tmpFile.RenameTo(f))
{
// tried to rename which failed. Let' delete the target file and try
// again
FileUtils.Delete(f);
if (!tmpFile.RenameTo(f))
{
throw new IOException(MessageFormat.Format(JGitText.Get().couldNotWriteFile, tmpFile
.GetPath(), f.GetPath()));
}
}
entry.LastModified = f.LastModified();
if (opt.GetAutoCRLF() != CoreConfig.AutoCRLF.FALSE)
{
entry.SetLength(f.Length());
}
else
{
// AutoCRLF wants on-disk-size
entry.SetLength((int)ol.GetSize());
}
}
示例11: PersonIdent
/// <summary>Creates new PersonIdent from config info in repository, with current time.
/// </summary>
/// <remarks>
/// Creates new PersonIdent from config info in repository, with current time.
/// This new PersonIdent gets the info from the default committer as available
/// from the configuration.
/// </remarks>
/// <param name="repo"></param>
public PersonIdent(Repository repo) : this(repo.GetConfig().Get(UserConfig.KEY))
{
}
示例12: Create
/// <summary>Create an index pack instance to load a new pack into a repository.</summary>
/// <remarks>
/// Create an index pack instance to load a new pack into a repository.
/// <p>
/// The received pack data and generated index will be saved to temporary
/// files within the repository's <code>objects</code> directory. To use the
/// data contained within them call
/// <see cref="RenameAndOpenPack()">RenameAndOpenPack()</see>
/// once the
/// indexing is complete.
/// </remarks>
/// <param name="db">the repository that will receive the new pack.</param>
/// <param name="is">
/// stream to read the pack data from. If the stream is buffered
/// use
/// <see cref="BUFFER_SIZE">BUFFER_SIZE</see>
/// as the buffer size for the stream.
/// </param>
/// <returns>a new index pack instance.</returns>
/// <exception cref="System.IO.IOException">a temporary file could not be created.</exception>
public static NGit.Transport.IndexPack Create(Repository db, InputStream @is)
{
string suffix = ".pack";
FilePath objdir = db.ObjectsDirectory;
FilePath tmp = FilePath.CreateTempFile("incoming_", suffix, objdir);
string n = tmp.GetName();
FilePath @base;
@base = new FilePath(objdir, Sharpen.Runtime.Substring(n, 0, n.Length - suffix.Length
));
NGit.Transport.IndexPack ip = new NGit.Transport.IndexPack(db, @is, @base);
ip.SetIndexVersion(db.GetConfig().Get(CoreConfig.KEY).GetPackIndexVersion());
return ip;
}
示例13: PackConfig
/// <summary>Create a configuration honoring the repository's settings.</summary>
/// <remarks>Create a configuration honoring the repository's settings.</remarks>
/// <param name="db">
/// the repository to read settings from. The repository is not
/// retained by the new configuration, instead its settings are
/// copied during the constructor.
/// </param>
public PackConfig(Repository db)
{
// Fields are initialized to defaults.
FromConfig(db.GetConfig());
}