-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe "Worktree Popup", :git, :nvim do | ||
let(:dir) { "worktree_test_#{SecureRandom.hex(4)}" } | ||
|
||
after do # Cleanup worktree dirs | ||
Dir[File.join(Dir.tmpdir, "worktree_test_*")].each do |tmpdir| | ||
FileUtils.rm_rf(tmpdir) | ||
end | ||
end | ||
|
||
describe "Actions" do | ||
describe "Checkout" do | ||
before do | ||
git.branch("worktree-test").checkout | ||
git.branch("master").checkout | ||
end | ||
|
||
it "creates a worktree for an existing branch and checks it out", :aggregate_failures do | ||
nvim.keys("ww") # Open popup/action | ||
nvim.keys("wor<cr>") # Select "worktree-test" branch | ||
nvim.keys("<cr>#{dir}<cr>") # go up level, new folder name | ||
|
||
expect(git.worktrees.map(&:dir).last).to match(%r{/#{dir}$}) | ||
expect(nvim.cmd("pwd").first).to match(%r{/#{dir}$}) | ||
end | ||
end | ||
|
||
describe "Create" do | ||
before do | ||
git.branch("worktree-test").checkout | ||
git.branch("master").checkout | ||
end | ||
|
||
it "creates a worktree for a new branch and checks it out", :aggregate_failures do | ||
nvim.input("create-worktree-test") # Branch name | ||
|
||
nvim.keys("wW") # Open popup/action | ||
nvim.keys("<cr>#{dir}<cr>") # go up level, new folder name | ||
nvim.keys("mas<cr>") # Set base branch to 'master' | ||
|
||
expect(git.worktrees.map(&:dir).last).to match(%r{/#{dir}$}) | ||
expect(nvim.cmd("pwd").first).to match(%r{/#{dir}$}) | ||
end | ||
end | ||
|
||
describe "Goto" do | ||
end | ||
|
||
describe "Move" do | ||
end | ||
|
||
describe "Delete" do | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ def dir_name(name) | |
name.match(%r{[^/]+/(?<dir_name>[^\.]+)})[:dir_name] | ||
end | ||
|
||
def ensure_installed(name) | ||
def ensure_installed(name, build: nil) | ||
tmp = File.join(PROJECT_DIR, "tmp") | ||
FileUtils.mkdir_p(tmp) | ||
|
||
|
@@ -17,7 +17,9 @@ def ensure_installed(name) | |
puts "Downloading dependency #{name} to #{dir}" | ||
Dir.mkdir(dir) | ||
Git.clone("[email protected]:#{name}.git", dir) | ||
Dir.chdir(dir) { system(build) } if build.present? | ||
end | ||
|
||
ensure_installed "nvim-lua/plenary.nvim" | ||
ensure_installed "nvim-telescope/telescope.nvim" | ||
ensure_installed "nvim-telescope/telescope-fzf-native.nvim", build: "make" |