本文整理汇总了C#中Branch类的典型用法代码示例。如果您正苦于以下问题:C# Branch类的具体用法?C# Branch怎么用?C# Branch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Branch类属于命名空间,在下文中一共展示了Branch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FinancialStatusByBranchController
public FinancialStatusByBranchController(Branch branch)
: base(UITableViewStyle.Grouped, null)
{
Autorotate = false;
this.branch = branch;
buildReport ();
}
示例2: Connect
public void Connect(Uri path)
{
// Try to see if ther is already a git repository inside the filesystem path
if (Repository.IsValid(m_fileSystemPath))
{
m_repository = new Repository(m_fileSystemPath, new RepositoryOptions());
}
else
{
var tempFolder = Guid.NewGuid().ToString("N");
m_bareWorkDirPath = System.IO.Path.Combine(m_fileSystemPath, tempFolder);
var ret = Repository.Clone(path.AbsoluteUri, m_bareWorkDirPath, new CloneOptions()
{
CredentialsProvider = (url, fromUrl, types) => new UsernamePasswordCredentials()
{
Password = m_password,
Username = m_userName,
},
Checkout = false,
IsBare = true,
});
m_repository = new Repository(m_bareWorkDirPath, new RepositoryOptions());
}
m_branch = m_repository.Branches[m_branchPath];
if (m_branch == null)
{
throw new Exception("Branch not found: " + m_branchPath);
}
}
示例3: LatestMergeCommit
public static Commit LatestMergeCommit(this Branch thisBranch, Branch otherBranch)
{
IEnumerable<Commit> otherBranchCommits = otherBranch.Commits;
if (otherBranchCommits.Contains(thisBranch.Tip))
{
// Current branch is merged back to otherBranch.
// So we find the last commit on otherBranch before this merge and all it's ancestors.
var otherTipAfterMerge =
otherBranchCommits.SkipWhile(c => c.Parents.All(p => p != thisBranch.Tip)).FirstOrDefault();
if (otherTipAfterMerge != null)
{
var thisTipBeforeMerge = otherTipAfterMerge.Parents.First(p => p != thisBranch.Tip);
otherBranchCommits =
new List<Commit> { thisTipBeforeMerge }.Concat(thisTipBeforeMerge.GetAllAncestors());
}
}
var branchCommits = thisBranch.Commits.Except(otherBranchCommits).ToList();
var branchCommitsMergedFromOtherBranch =
branchCommits.Where(c => c.IsMergeFrom(otherBranchCommits)).ToList();
if (branchCommitsMergedFromOtherBranch.Any())
{
return branchCommitsMergedFromOtherBranch.First().GetSingleParentFrom(otherBranchCommits);
}
if (branchCommits.Any())
{
return branchCommits.Last().GetSingleParentFrom(otherBranchCommits);
}
return null;
}
示例4: Login
public User Login(string username, string password)
{
var session = NHibernateSessionManager.GetLocalSession();
var macAddress = _clientAdapter.GetCurrentClientMacAddress();
var user = _userRepository.LoginActiveUser(username, password);
var terminal = _terminalRepository.FindByMac(macAddress);
if (user.IsNull())
{
throw new ApplicationException(@"User not found");
}
if (terminal == null)
{
session.DoTransactional(sess =>
terminal = _terminalRepository.Insert(
new Terminal(
string.Format(@"T-{0}/{1:00}", user.Employee.Branch.Code ,_terminalRepository.Count() + 1),
macAddress,
user.Employee.Branch
)
)
);
}
LoggedInUser = user;
LoggedInUserBranch = user.Employee.Branch;
LoggedInTerminal = terminal;
return user;
}
示例5: Push
/// <summary>
/// Push the specified branch to its tracked branch on the remote.
/// </summary>
/// <param name="network">The <see cref="Network"/> being worked with.</param>
/// <param name="branch">The branch to push.</param>
/// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param>
/// <exception cref="LibGit2SharpException">Throws if either the Remote or the UpstreamBranchCanonicalName is not set.</exception>
public static void Push(
this Network network,
Branch branch,
PushOptions pushOptions = null)
{
network.Push(new[] { branch }, pushOptions);
}
示例6: GetUnknownBranchSuffix
static string GetUnknownBranchSuffix(Branch branch)
{
var unknownBranchSuffix = branch.Name.Split('-', '/');
if (unknownBranchSuffix.Length == 1)
return branch.Name;
return unknownBranchSuffix[1];
}
示例7: EnsureVersionIsValid
void EnsureVersionIsValid(SemanticVersion version, Branch branch, BranchType branchType)
{
var msg = string.Format("Branch '{0}' doesn't respect the {1} branch naming convention. ",
branch.Name, branchType);
if (version.PreReleaseTag.HasTag())
{
throw new ErrorException(msg + string.Format("Supported format is '{0}-Major.Minor.Patch'.", branchType.ToString().ToLowerInvariant()));
}
switch (branchType)
{
case BranchType.Hotfix:
if (version.Patch == 0)
{
throw new ErrorException(msg + "A patch segment different than zero is required.");
}
break;
case BranchType.Release:
if (version.Patch != 0)
{
throw new ErrorException(msg + "A patch segment equals to zero is required.");
}
break;
case BranchType.Unknown:
break;
default:
throw new NotSupportedException(string.Format("Unexpected branch type {0}.", branchType));
}
}
示例8: RenameBranchDialog
/// <summary>Create <see cref="RenameBranchDialog"/>.</summary>
/// <param name="branch">Branch to rename.</param>
/// <exception cref="ArgumentNullException"><paramref name="branch"/> == <c>null</c>.</exception>
public RenameBranchDialog(Branch branch)
{
Verify.Argument.IsNotNull(branch, "branch");
Verify.Argument.IsFalse(branch.IsDeleted, "branch",
Resources.ExcObjectIsDeleted.UseAsFormat("Branch"));
_branch = branch;
InitializeComponent();
Localize();
var inputs = new IUserInputSource[]
{
_newNameInput = new TextBoxInputSource(_txtNewName),
};
_errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);
SetupReferenceNameInputBox(_txtNewName, ReferenceType.LocalBranch);
var branchName = branch.Name;
_txtOldName.Text = branchName;
_txtNewName.Text = branchName;
_txtNewName.SelectAll();
GitterApplication.FontManager.InputFont.Apply(_txtNewName, _txtOldName);
_controller = new RenameBranchController(branch) { View = this };
}
示例9: ElectronicObject
public ElectronicObject(string catalogueNumber, string manufacturer, string model, string description, int quantity, Branch category, decimal price, Color color, double display, int capacity)
: base(catalogueNumber, manufacturer, model, description, quantity, category, price)
{
this.display = display;
this.capacity = capacity;
this.color = color;
}
示例10: GetBranchConfiguration
public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit currentCommit, IRepository repository, bool onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList<Branch> excludedInheritBranches = null)
{
var matchingBranches = LookupBranchConfiguration(config, currentBranch);
if (matchingBranches.Length == 0)
{
var branchConfig = new BranchConfig();
ConfigurationProvider.ApplyBranchDefaults(config, branchConfig);
return new KeyValuePair<string, BranchConfig>(string.Empty, branchConfig);
}
if (matchingBranches.Length == 1)
{
var keyValuePair = matchingBranches[0];
var branchConfiguration = keyValuePair.Value;
if (branchConfiguration.Increment == IncrementStrategy.Inherit)
{
return InheritBranchConfiguration(onlyEvaluateTrackedBranches, repository, currentCommit, currentBranch, keyValuePair, branchConfiguration, config, excludedInheritBranches);
}
return keyValuePair;
}
const string format = "Multiple branch configurations match the current branch branchName of '{0}'. Matching configurations: '{1}'";
throw new Exception(string.Format(format, currentBranch.Name, string.Join(", ", matchingBranches.Select(b => b.Key))));
}
示例11: BranchWrapper
public BranchWrapper(Repository repo, Branch branch)
{
this.repo = repo;
this.branch = branch;
IsRemote = branch.IsRemote;
if (branch.TrackedBranch != null)
{
TrackedBranch = new BranchWrapper(repo, branch.TrackedBranch);
}
IsTracking = branch.IsTracking;
TrackingDetails = (Func<object, Task<object>>)(async (j) => { return branch.TrackingDetails; });
IsCurrentRepositoryHead = (Func<object, Task<object>>)(async (j) => { return branch.IsCurrentRepositoryHead; });
Tip = async (j) => { return new CommitWrapper(branch.Tip); };
UpstreamBranchCanonicalName = (Func<object, Task<object>>)(async (j) => { return branch.UpstreamBranchCanonicalName; });
Remote = branch.Remote;
CanonicalName = branch.CanonicalName;
Commits = (Func<object, Task<object>>)(async (j) => {
if (j != null)
{
Commit after = repo.Lookup<Commit>((string)j);
Commit until = branch.Tip;
Commit ancestor = repo.Commits.FindMergeBase(after, until) ?? after;
return CommitsAfter(after, until, ancestor).Distinct().Select(c => new CommitWrapper(c));
}
else
{
return branch.Commits.Select(c => new CommitWrapper(c));
}
});
Name = branch.Name;
}
示例12: GetBranchConfiguration
/// <summary>
/// Gets the <see cref="BranchConfig"/> for the current commit.
/// </summary>
public static BranchConfig GetBranchConfiguration(GitVersionContext context, Branch targetBranch, IList<Branch> excludedInheritBranches = null)
{
var matchingBranches = LookupBranchConfiguration(context.FullConfiguration, targetBranch).ToArray();
BranchConfig branchConfiguration;
if (matchingBranches.Length > 0)
{
branchConfiguration = matchingBranches[0];
if (matchingBranches.Length > 1)
{
Logger.WriteWarning(string.Format(
"Multiple branch configurations match the current branch branchName of '{0}'. Using the first matching configuration, '{1}'. Matching configurations include: '{2}'",
targetBranch.FriendlyName,
branchConfiguration.Name,
string.Join("', '", matchingBranches.Select(b => b.Name))));
}
}
else
{
Logger.WriteInfo(string.Format(
"No branch configuration found for branch {0}, falling back to default configuration",
targetBranch.FriendlyName));
branchConfiguration = new BranchConfig { Name = string.Empty };
ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, branchConfiguration, "");
}
return branchConfiguration.Increment == IncrementStrategy.Inherit ?
InheritBranchConfiguration(context, targetBranch, branchConfiguration, excludedInheritBranches) :
branchConfiguration;
}
示例13: CalculateWhenMultipleParents
static Branch[] CalculateWhenMultipleParents(IRepository repository, Commit currentCommit, ref Branch currentBranch, Branch[] excludedBranches)
{
var parents = currentCommit.Parents.ToArray();
var branches = repository.Branches.Where(b => !b.IsRemote && b.Tip == parents[1]).ToList();
if (branches.Count == 1)
{
var branch = branches[0];
excludedBranches = new[]
{
currentBranch,
branch
};
currentBranch = branch;
}
else if (branches.Count > 1)
{
currentBranch = branches.FirstOrDefault(b => b.Name == "master") ?? branches.First();
}
else
{
var possibleTargetBranches = repository.Branches.Where(b => !b.IsRemote && b.Tip == parents[0]).ToList();
if (possibleTargetBranches.Count > 1)
{
currentBranch = possibleTargetBranches.FirstOrDefault(b => b.Name == "master") ?? possibleTargetBranches.First();
}
else
{
currentBranch = possibleTargetBranches.FirstOrDefault() ?? currentBranch;
}
}
Logger.WriteInfo("HEAD is merge commit, this is likely a pull request using " + currentBranch.Name + " as base");
return excludedBranches;
}
示例14: CreateBranch
/// <summary>
/// Create New Branch
/// </summary>
/// <param name="NewBranch"></param>
public void CreateBranch(Branch NewBranch)
{
string qryInsertBranch =
@"INSERT INTO [dbo].[Company]
([BranchID]
, [CompanyID]
, [BranchRegion]
, [BranchCode]
, [BranchName]
, [BranchHotelName]
, [BranchSpaName]
, [BranchAddress]
, [BranchCity]
, [BranchState]
, [BranchCountry]
, [BranchContactNo]
, [BranchComment]
, [BranchCreatedBy])
values
(@BranchID, @CompanyID, @BranchRegion, @BranchCode, @BranchName,
@BranchHotelName, @BranchSpaName, @BranchAddress, @BranchCity,
@BranchState, @BranchCountry, @BranchContactNo, @BranchComment, @BranchCreatedBy)";
//creates new Branch
this._con.Query<int>(qryInsertBranch, NewBranch);
}
示例15: NumberOfCommitsOnBranchSinceCommit
public int NumberOfCommitsOnBranchSinceCommit(Branch branch, Commit commit)
{
var olderThan = branch.Tip.Committer.When;
return branch.Commits
.TakeWhile(x => x != commit)
.Count();
}