コード例 #1
0
ファイル: Remotes.js プロジェクト: FezVrasta/brackets-git
                q = q.then(function () {
                    var op;

                    if (pushConfig.pushToNew) {
                        op = Git.pushToNewUpstream(pushConfig.remote, pushConfig.branch);
                    } else if (pushConfig.strategy === "DEFAULT") {
                        op = Git.push(pushConfig.remote, pushConfig.branch);
                    } else if (pushConfig.strategy === "FORCED") {
                        op = Git.pushForced(pushConfig.remote, pushConfig.branch);
                    } else if (pushConfig.strategy === "DELETE_BRANCH") {
                        op = Git.deleteRemoteBranch(pushConfig.remote, pushConfig.branch);
                    }
                    return ProgressDialog.show(op)
                        .then(function (result) {
                            return ProgressDialog.waitForClose().then(function () {
                                showPushResult(result);
                            });
                        })
                        .catch(function (err) {
                            ErrorHandler.showError(err, "Pushing to remote failed");
                        });
                });
コード例 #2
0
        decideRemoteBranch(remoteName).spread(function (remoteBranch, newUpstream) {
            var p;
            if (newUpstream) {
                p = Git.pushToNewUpstream(remoteName, remoteBranch);
            } else {
                p = Git.push(remoteName, remoteBranch);
            }
            return p.catch(function (err) {

                if (!ErrorHandler.contains(err, "git remote add <name> <url>")) {
                    throw err;
                }

                // this will ask user to enter an origin url for pushing
                // it's pretty dumb because if he enters invalid url, he has to go to console again
                // but our users are very wise so that definitely won't happen :)))

                return new Promise(function (resolve, reject) {
                    Utils.askQuestion(Strings.SET_ORIGIN_URL, _.escape(Strings.URL)).then(function (url) {
                        Git.createRemote("origin", url)
                            .then(function () {
                                return Git.push("origin");
                            })
                            .then(resolve)
                            .catch(reject);
                    });
                });

            }).catch(function (err) {

                throw err;
                /* this shouldn't be needed anymore
                if (typeof err !== "string") { throw err; }
                var m = err.match(/git push --set-upstream (\S+) (\S+)/);
                if (!m) { throw err; }
                return Git.pushToNewUpstream(m[1], m[2]);
                */

            }).catch(function (err) {

                var validFail = false;
                if (ErrorHandler.contains(err, "rejected because")) {
                    validFail = true;
                }
                if (validFail) {
                    throw err;
                }
                console.warn("Traditional push failed: " + err);
                return handleGitPushWithPassword(err, remoteName);

            }).then(function (result) {

                var template = [
                    "<h3>{{flagDescription}}</h3>",
                    "Info:",
                    "Remote url - {{remoteUrl}}",
                    "Local branch - {{from}}",
                    "Remote branch - {{to}}",
                    "Summary - {{summary}}",
                    "<h4>Status - {{status}}</h4>"
                ].join("<br>");

                Dialogs.showModalDialog(
                    DefaultDialogs.DIALOG_ID_INFO,
                    Strings.GIT_PUSH_RESPONSE, // title
                    Mustache.render(template, result) // message
                );

            }).catch(function (err) {
                console.warn("Pushing to remote repositories with username / password is not fully supported! See github page/issues for details.");
                ErrorHandler.showError(err, "Pushing to remote repository failed.");
            });
        }).finally(function () {