yay got multiple remotes fetching working

This commit is contained in:
Peter Cottle 2013-10-06 18:09:38 -07:00
parent a16204fea3
commit 9fa8c1383d
8 changed files with 203 additions and 27 deletions

View file

@ -7,6 +7,10 @@ var GitError = Errors.GitError;
var Warning = Errors.Warning;
var CommandResult = Errors.CommandResult;
var crappyUnescape = function(str) {
return str.replace(/'/g, "'").replace(///g, "/");
};
var commandConfig = {
commit: {
sc: /^(gc|git ci)($|\s)/,
@ -171,21 +175,50 @@ var commandConfig = {
},
fetch: {
regex: /^git +fetch *?$/,
regex: /^git +fetch($|\s)/,
execute: function(engine, command) {
var options = {};
if (!engine.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
var generalArgs = command.getGeneralArgs();
command.oneArgImpliedOrigin(generalArgs);
command.twoArgsImpliedOrigin(generalArgs);
if (generalArgs[0] !== 'origin') {
throw new GitError({
msg: intl.str('git-error-options')
msg: intl.todo(
generalArgs[0] + ' is not a remote in your repository! try origin'
)
});
}
engine.fetch();
if (generalArgs[1]) {
var branchName = crappyUnescape(generalArgs[1]);
if (!engine.refs[branchName]) {
throw new GitError({
msg: intl.todo(branchName + ' is not a branch!')
});
}
var branch = engine.resolveID(branchName);
if (branch.get('type') !== 'branch') {
throw new GitError({
msg: intl.todo(branchName + ' is not a branch!')
});
}
var tracking = branch.getRemoteTrackingBranchID();
if (!tracking) {
throw new GitError({
msg: intl.todo(branchName + ' is not a remote tracking branch!')
});
}
options.branches = [engine.refs[tracking]];
}
engine.fetch(options);
}
},