Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #171 from UziTech/rebase-pull
Browse files Browse the repository at this point in the history
Rebase on pull
  • Loading branch information
UziTech authored Dec 20, 2019
2 parents a1a1248 + 50a6ee7 commit 49f1fe3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/commands/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export default {
},
async command(filePaths, statusBar, git = gitCmd, notifications = Notifications, title = "Pull") {
const root = await helper.getRoot(filePaths, git);
const rebase = atom.config.get("git-menu.rebaseOnPull");
await helper.checkGitLock(root);
statusBar.show("Pulling...");
const result = await git.pull(root, false);
const result = await git.pull(root, rebase, false);
notifications.addGit(title, result);
helper.refreshAtom(root);
return {
Expand Down
11 changes: 9 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ export default {
default: true,
order: 3,
},
rebaseOnPull: {
type: "boolean",
title: "Rebase on Pull",
description: "Rebase instead of merge on Pull and Sync",
default: false,
order: 4,
},
confirmationDialogs: {
type: "object",
order: 4,
order: 5,
properties: Object.keys(commands).reduce((prev, cmd, idx) => {
if (commands[cmd].confirm) {
const label = commands[cmd].label || commands[cmd].confirm.label;
Expand Down Expand Up @@ -64,7 +71,7 @@ export default {
},
contextMenuItems: {
type: "object",
order: 5,
order: 6,
properties: Object.keys(commands).reduce((prev, cmd, idx) => {
if (commands[cmd].label) {
prev[cmd] = {
Expand Down
6 changes: 4 additions & 2 deletions lib/git-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,16 @@ export default {
/**
* Pull commits from remote repo
* @param {string} cwd Current Working Directory
* @param {bool} [rebase=false] Add --rebase flag
* @param {bool} [force=false] Add --force flag
* @param {bool} verbose Not add the --quiet flag
* @return {Promise} {string} The result of the command
*/
pull(cwd, force = false, verbose = isVerbose()) {
pull(cwd, rebase = false, force = false, verbose = isVerbose()) {
const verboseArg = (verbose ? "--verbose" : "--quiet");
const forceArg = (force ? "--force" : "");
return this.cmd(cwd, ["pull", verboseArg, forceArg]);
const rebaseArg = (rebase ? "--rebase" : "");
return this.cmd(cwd, ["pull", verboseArg, forceArg, rebaseArg]);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/commit-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe("commit", function () {
it("should call git.pull", async function () {
spyOn(this.git, "pull").and.callThrough();
await commit.command(this.filePaths, statusBar, this.git, Notifications, this.dialog);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, false);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, false, false);
});

it("should show git notification for pull results", async function () {
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/commit-staged-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe("commit-staged", function () {
it("should call git.pull", async function () {
spyOn(this.git, "pull").and.callThrough();
await commitStaged.command(this.filePaths, statusBar, this.git, Notifications, this.dialog);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, false);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, false, false);
});

it("should show git notification for pull results", async function () {
Expand Down
9 changes: 8 additions & 1 deletion spec/commands/pull-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ describe("pull", function () {
it("should call git.pull", async function () {
spyOn(this.git, "pull").and.callThrough();
await pull.command(this.filePaths, statusBar, this.git, Notifications);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, false);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, false, false);
});

it("should call git.pull with rebase config", async function () {
spyOn(this.git, "pull").and.callThrough();
atom.config.set("git-menu.rebaseOnPull", true);
await pull.command(this.filePaths, statusBar, this.git, Notifications);
expect(this.git.pull).toHaveBeenCalledWith(this.gitRoot, true, false);
});

it("should show git notification for pull results", async function () {
Expand Down

0 comments on commit 49f1fe3

Please sign in to comment.