Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrettierCI master Sync #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 24 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
#!/usr/bin/env node

var cmd = require("node-cmd");
var cmd = require('node-cmd')

cmd.get("git remote get-url origin", function(err, data, stderr) {
if (data && data !== "") {
var remoteUrl = data.split(".git")[0];
cmd.get("git rev-parse --abbrev-ref HEAD", function(err, data, stderr) {
if (data && data !== "") {
var branch = data;
cmd.get('git remote get-url origin', function(err, data, stderr) {
if (data && data !== '') {
var remoteUrl = data.split('.git')[0]
cmd.get('git rev-parse --abbrev-ref HEAD', function(err, data, stderr) {
if (data && data !== '') {
var branch = data

console.log("pushing branch " + branch + " to origin");
cmd.get("git push -u origin " + branch, function() {
if (remoteUrl.indexOf("git@") === 0) {
remoteUrl = remoteUrl.replace(":", "/");
remoteUrl = remoteUrl.replace("git@", "https://");
console.log('pushing branch ' + branch + ' to origin')
cmd.get('git push -u origin ' + branch, function() {
if (remoteUrl.indexOf('git@') === 0) {
remoteUrl = remoteUrl.replace(':', '/')
remoteUrl = remoteUrl.replace('git@', 'https://')
}
if (remoteUrl.indexOf("github.com") > -1) {
remoteUrl = remoteUrl + "/compare/" + branch;
if (remoteUrl.indexOf('github.com') > -1) {
remoteUrl = remoteUrl + '/compare/' + branch
}
if (remoteUrl.indexOf("gitlab.com") > -1) {
remoteUrl =
remoteUrl +
"/merge_requests/new?merge_request%5Bsource_branch%5D=" +
branch;
if (remoteUrl.indexOf('gitlab.com') > -1) {
remoteUrl = remoteUrl + '/merge_requests/new?merge_request%5Bsource_branch%5D=' + branch
}
if (remoteUrl.indexOf("bitbucket.org") > -1) {
remoteUrl =
remoteUrl + "/pull-requests/new?source=" + branch + "&t=1";
if (remoteUrl.indexOf('bitbucket.org') > -1) {
remoteUrl = remoteUrl + '/pull-requests/new?source=' + branch + '&t=1'
}

console.log("pull request url: " + remoteUrl);
cmd.run("open " + remoteUrl);
});
console.log('pull request url: ' + remoteUrl)
cmd.run('open ' + remoteUrl)
})
}
});
})
} else {
console.log("Not a git repository");
console.log('Not a git repository')
}
});
})