Skip to content

Commit

Permalink
Add support for config merges in Sheldon
Browse files Browse the repository at this point in the history
When you're first setting up Sheldon, you'll likely have multiple
variants of the same file across several hosts. It's likely that each
variant has settings / snippets that offer value, and that you'd rather
not lose. This branch introduces support for a new Sheldon#merge,
allowing a user to merge their local version of a file with the "master"
version saved in Sheldon. This process can be repeated across all your
hosts until your "master" file contains the best bits of all your
different config variants.
  • Loading branch information
dvjones89 committed Dec 23, 2018
1 parent b4aa78c commit 0ac43d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sheldon.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative "sheldon/brain"
require_relative "sheldon/builder"
require_relative "sheldon/helpers"
require_relative "sheldon/file_merger"
require_relative "sheldon/memory"
require_relative "sheldon/sheldon"
require_relative "sheldon/exceptions"
Expand Down
25 changes: 25 additions & 0 deletions lib/sheldon/file_merger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class FileMerger
require 'git'
require 'byebug'

def initialize(brain, cue)
@brain = brain
@cue = cue
# @git_directory = File.join(brain.location, "git-temp")
@git_directory = File.join("/Users/dave/Desktop", "git-test")
@git_scratchfile = File.join(@git_directory, "scratch.txt")
end

def merge!(path_to_users_file)
setup_git_scratchpad
end

private

def setup_git_scratchpad
git = Git.init(@git_directory)
File.open(@git_scratchfile, "w") { |f| f.write("") }
git.add
git.commit("initial commit")
end
end

0 comments on commit 0ac43d3

Please sign in to comment.