partway through git strings

This commit is contained in:
Peter Cottle 2013-03-02 12:57:34 -08:00
parent d17d131d24
commit efabfa4378
6 changed files with 355 additions and 81 deletions

View file

@ -123,7 +123,10 @@ GitEngine.prototype.printTree = function(tree) {
};
GitEngine.prototype.printAndCopyTree = function() {
window.prompt('Copy the tree string below', this.printTree());
window.prompt(
intl.str('Copy the tree string below'),
this.printTree()
);
};
GitEngine.prototype.loadTree = function(tree) {
@ -392,7 +395,7 @@ GitEngine.prototype.makeCommit = function(parents, id, options) {
GitEngine.prototype.acceptNoGeneralArgs = function() {
if (this.generalArgs.length) {
throw new GitError({
msg: "That command accepts no general arguments"
msg: intl.str('git-error-no-general-args')
});
}
};
@ -406,12 +409,24 @@ GitEngine.prototype.validateArgBounds = function(args, lower, upper, option) {
if (args.length < lower) {
throw new GitError({
msg: 'I expect at least ' + String(lower) + ' argument(s) ' + what
msg: intl.str(
'git-error-args-few',
{
lower: String(lower),
what: what
}
)
});
}
if (args.length > upper) {
throw new GitError({
msg: 'I expect at most ' + String(upper) + ' argument(s) ' + what
msg: intl.str(
'git-error-args-many',
{
upper: String(upper),
what: what
}
)
});
}
};
@ -465,9 +480,16 @@ GitEngine.prototype.revert = function(whichCommits) {
_.each(toRebase, function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str(
'git-revert-msg',
{
oldCommit: this.resolveName(oldCommit),
oldMsg: oldCommit.get('commitMessage')
}
);
var newCommit = this.makeCommit([base], newId, {
commitMessage: 'Reverting ' + this.resolveName(oldCommit) +
': "' + oldCommit.get('commitMessage') + '"'
commitMessage: commitMessage
});
base = newCommit;
@ -492,15 +514,12 @@ GitEngine.prototype.revert = function(whichCommits) {
GitEngine.prototype.resetStarter = function() {
if (this.commandOptions['--soft']) {
throw new GitError({
msg: "You can't use --soft because there is no concept of stashing" +
" changes or staging files, so you will lose your progress." +
" Try using interactive rebasing (or just rebasing) to move commits."
msg: intl.str('git-error-soft')
});
}
if (this.commandOptions['--hard']) {
this.command.addWarning(
'Nice! You are using --hard. The default behavior is a hard reset in ' +
"this demo, so don't worry about specifying the option explicity"
intl.str('git-warning-hard')
);
// dont absorb the arg off of --hard
this.generalArgs = this.generalArgs.concat(this.commandOptions['--hard']);
@ -510,7 +529,7 @@ GitEngine.prototype.resetStarter = function() {
if (this.getDetachedHead()) {
throw new GitError({
msg: "Cant reset in detached head! Use checkout if you want to move"
msg: intl.str('git-error-reset-detached')
});
}
@ -531,8 +550,10 @@ GitEngine.prototype.cherrypickStarter = function() {
// and check that its not upstream
if (set[commit.get('id')]) {
throw new GitError({
msg: 'The commit ' + commit.get('id') +
' already exists in your changes set, aborting!'
msg: intl.str(
'git-error-already-exists',
{ commit: commit.get('id') }
)
});
}
}, this);
@ -585,23 +606,19 @@ GitEngine.prototype.commitStarter = function() {
if (this.commandOptions['-am'] && (
this.commandOptions['-a'] || this.commandOptions['-m'])) {
throw new GitError({
msg: "You can't have -am with another -m or -a!"
msg: intl.str('git-error-options')
});
}
var msg = null;
var args = null;
if (this.commandOptions['-a']) {
this.command.addWarning('No need to add files in this demo');
this.command.addWarning(intl.str('git-warning-add'));
}
if (this.commandOptions['-am']) {
args = this.commandOptions['-am'];
this.validateArgBounds(args, 1, 1, '-am');
this.command.addWarning("Don't worry about adding files in this demo. I'll take " +
"down your commit message anyways, but you can commit without a message " +
"in this demo as well");
msg = args[0];
}
@ -635,7 +652,7 @@ GitEngine.prototype.commit = function() {
var newCommit = this.makeCommit([targetCommit], id);
if (this.getDetachedHead()) {
this.command.addWarning('Warning!! Detached HEAD state');
this.command.addWarning(intl.str('git-warning-detached'));
}
this.setTargetLocation(this.HEAD, newCommit);
@ -683,7 +700,13 @@ GitEngine.prototype.resolveRelativeRef = function(commit, relative) {
}
if (!next) {
var msg = "Commit " + commit.id + " doesn't have a " + matches[0];
var msg = intl.str(
'git-error-relative-ref',
{
commit: commit.id,
match: matches[0]
}
);
throw new GitError({
msg: msg
});
@ -712,16 +735,15 @@ GitEngine.prototype.resolveStringRef = function(ref) {
if (matches) {
startRef = matches[1];
relative = matches[2];
}
else {
} else {
throw new GitError({
msg: 'unknown ref ' + ref
msg: intl.str('git-error-exist', {ref: ref})
});
}
if (!this.refs[startRef]) {
throw new GitError({
msg: 'the ref ' + startRef +' does not exist.'
msg: intl.str('git-error-exist', {ref: ref})
});
}
var commit = this.getCommitFromRef(startRef);