jiranch
Version:
Easily create Git branches from your sprint issues
1 lines • 2.65 kB
JavaScript
;var __awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(a,u){function i(e){try{c(n.next(e))}catch(e){u(e)}}function o(e){try{c(n.throw(e))}catch(e){u(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,a,u,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return u={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function o(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,o[0]&&(i=0)),i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPullNeeded=void 0;var utils_1=require("./utils"),ora_1=__importDefault(require("ora")),inquirer_1=__importDefault(require("inquirer")),shared_1=require("../shared");function checkPullNeeded(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,n,a;return __generator(this,(function(u){switch(u.label){case 0:return e=(0,ora_1.default)("Fetching remote").start(),[4,(0,utils_1.exec)("git fetch")];case 1:return u.sent(),[4,(0,utils_1.exec)("git status -uno")];case 2:return t=u.sent().stdout,t.includes("Your branch is behind")?(r=/Your branch is behind '([\w\/]+)'/.exec(t),n=r[1],e.warn("Your local branch is behind ".concat(n,".")),[4,inquirer_1.default.prompt([{type:"boolean",name:"pull",message:"Update branch? (y/n)",default:"y"}])]):(e.succeed("Branch up to date."),[2]);case 3:return a=u.sent().pull,(0,shared_1.confirmed)(a)?(e.start("Merging"),[4,(0,utils_1.exec)("git merge ".concat(n))]):[3,5];case 4:u.sent(),e.succeed("Branch up to date."),u.label=5;case 5:return[2]}}))}))}exports.checkPullNeeded=checkPullNeeded;