Permalink
Browse files

subtree now updates the owning remote to the commit after the subtree…

… merge
  • Loading branch information...
1 parent 4cfe68b commit d67e985e666f62be9f566c340334b58d94d31dde @gburgett committed Apr 9, 2013
@@ -108,7 +108,7 @@ private ILinking Linking
get { return _linking ?? (_linking = GetService<ILinking>()); }
}
- public IEnumerable<ITfsChangeset> GetChangesets(string path, long startVersion, GitTfsRemote remote)
+ public IEnumerable<ITfsChangeset> GetChangesets(string path, long startVersion, IGitTfsRemote remote)
{
var changesets = VersionControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full,
null, new ChangesetVersionSpec((int) startVersion), VersionSpec.Latest, int.MaxValue, true,
@@ -55,7 +55,7 @@ public ITfsChangeset GetLatestChangeset(IGitTfsRemote remote)
return _script.Changesets.LastOrDefault().AndAnd(x => BuildTfsChangeset(x, remote));
}
- public IEnumerable<ITfsChangeset> GetChangesets(string path, long startVersion, GitTfsRemote remote)
+ public IEnumerable<ITfsChangeset> GetChangesets(string path, long startVersion, IGitTfsRemote remote)
{
return _script.Changesets.Where(x => x.Id >= startVersion).Select(x => BuildTfsChangeset(x, remote));
}
View
@@ -90,6 +90,7 @@ public int DoAdd(string tfsUrl, string tfsRepositoryPath)
var fetch = Squash ? this._quickFetch : this._fetch;
+ bool didCreate = false;
var tfsUri = new Uri(tfsUrl);
IGitTfsRemote owner = _globals.Repository.ReadAllTfsRemotes().FirstOrDefault(x => string.IsNullOrEmpty(x.TfsRepositoryPath) && !x.Id.StartsWith("subtree/") && tfsUri.Equals(x.TfsUrl));
if (owner == null)
@@ -102,6 +103,7 @@ public int DoAdd(string tfsUrl, string tfsRepositoryPath)
RemoteOptions = _remoteOptions
});
_stdout.WriteLine("-> new owning remote " + owner.Id);
+ didCreate = true;
}
else
{
@@ -124,20 +126,28 @@ public int DoAdd(string tfsUrl, string tfsRepositoryPath)
_stdout.WriteLine("-> new remote " + remote.Id);
int result = fetch.Run(remote.Id);
-
+
if (result == GitTfsExitCodes.OK)
{
+
var p = Prefix.Replace(" ", "\\ ");
- List<string> args = new List<string>(){"subtree", "add", "--prefix=" + p, remote.RemoteRef};
- if (Squash)
- {
- args.Add("--squash");
- }
+
+ List<string> args = new List<string>(){"subtree", "add",
+ "--prefix=" + p,
+ remote.RemoteRef
+ };
command(args);
+ //update the owner remote to point at the commit where the newly created subtree was merged.
+ var commit = _globals.Repository.GetCurrentCommit();
+ owner.UpdateRef(commit, remote.MaxChangesetId);
+
result = GitTfsExitCodes.OK;
}
+
+
+
return result;
}
@@ -157,10 +167,6 @@ public int DoPull(string remoteId)
{
var p = Prefix.Replace(" ", "\\ ");
List<string> args = new List<string>(){ "subtree", "merge", "--prefix=" + p, remote.RemoteRef };
- if(Squash)
- {
- args.Add("--squash");
- }
command(args);
result = GitTfsExitCodes.OK;
}
@@ -229,6 +229,11 @@ public GitCommit GetCommit(string commitish)
return new GitCommit(_repository.Lookup<Commit>(commitish));
}
+ public String GetCurrentCommit()
+ {
+ return _repository.Head.Commits.First().Sha;
+ }
+
public IEnumerable<TfsChangesetInfo> GetLastParentTfsCommits(string head)
{
return GetLastParentTfsCommits(head, false);
@@ -586,7 +586,7 @@ private long Checkin(string head, string parent, ITfsWorkspace workspace, Checki
public bool MatchesUrlAndRepositoryPath(string tfsUrl, string tfsRepositoryPath)
{
- return MatchesTfsUrl(tfsUrl) && TfsRepositoryPath.Equals(tfsRepositoryPath, StringComparison.OrdinalIgnoreCase);
+ return MatchesTfsUrl(tfsUrl) && TfsRepositoryPath != null && TfsRepositoryPath.Equals(tfsRepositoryPath, StringComparison.OrdinalIgnoreCase);
}
private bool MatchesTfsUrl(string tfsUrl)
@@ -27,6 +27,7 @@ public interface IGitRepository : IGitHelpers
bool WorkingCopyHasUnstagedOrUncommitedChanges { get; }
void CopyBlob(string sha, string outputFile);
GitCommit GetCommit(string commitish);
+ string GetCurrentCommit();
Dictionary<string, GitObject> GetObjects();
string GetCommitMessage(string head, string parentCommitish);
string GetCommitMessage(string commitish);
@@ -10,7 +10,7 @@ public interface ITfsHelper
string Url { get; set; }
string Username { get; set; }
string Password { get; set; }
- IEnumerable<ITfsChangeset> GetChangesets(string path, long startVersion, GitTfsRemote remote);
+ IEnumerable<ITfsChangeset> GetChangesets(string path, long startVersion, IGitTfsRemote remote);
void WithWorkspace(string directory, IGitTfsRemote remote, TfsChangesetInfo versionToFetch, Action<ITfsWorkspace> action);
IShelveset CreateShelveset(IWorkspace workspace, string shelvesetName);
IEnumerable<IWorkItemCheckinInfo> GetWorkItemInfos(IEnumerable<string> workItems, TfsWorkItemCheckinAction checkinAction);

0 comments on commit d67e985

Please sign in to comment.