Kobold 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd92e1c7f290dbd4fe42c2a497339329ee47ebb6249e26ec5ec08ccd9c9eba3d
4
- data.tar.gz: 0a5163797dca83c701b56e15d862fa9e7f2b7eb3d749a47c44d4f3547dc15ca7
3
+ metadata.gz: 3365a9b108ba3abccb20d4040f8f10c2b3cfeafaffcb1eab97f8bb6ec31c96f2
4
+ data.tar.gz: d5449335967f96c07777761a95a5de46b4a61857fd0c782b85dbfc8ab9ef7c20
5
5
  SHA512:
6
- metadata.gz: 35b37e639f5907fd4ea8d67b6819f704451892a495fe4574ed2bf8f49387ff9be153ac9e70b38df88a9c4dd75a3ab635e1213d08f6b88809d0481a3df714d0b3
7
- data.tar.gz: ae51f481be6391b40610a13bedd6a36158b17cf0bdc06ac2b8d2ba155019ed21367d9be144e24084bcacb0136de17fb56003b295b9eb198bb1c0bc5cd21891d9
6
+ metadata.gz: 65f41daea3213f01c72847b0cf4e51cc86580d1c514f3d89575273fb1f0437c720dce10bbc455c59ef8fa733eb59f433c78c2102cbd88856dab15ac4068422eb
7
+ data.tar.gz: 2e12df3ae02950f89743efe353855c86409073d5031af3eba41c8c1ab4e5d7dc18d85e3e3546fbcf05c799ceef49cb09b222b7877d86193d6c4d120c758f0281
data/exe/kobold CHANGED
@@ -52,8 +52,14 @@ else
52
52
  when "update"
53
53
  when "list"
54
54
  Kobold.list
55
+ when "fetch"
56
+ Kobold.fetch
55
57
  when "init"
56
58
  Kobold.init
59
+ when "version"
60
+ Kobold.version
61
+ when "v"
62
+ Kobold.version
57
63
  else
58
64
  print cmd.help
59
65
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tty-config"
4
+ require 'fileutils'
5
+ require 'git'
6
+
7
+ #require_relative "Kobold/vars.rb"
8
+
9
+ module Kobold
10
+ class << self
11
+ def fetch
12
+ Kobold.first_time_setup if !File.directory? "#{KOBOLD_DIR}/repo_cache"
13
+ if !File.file? "#{Dir.pwd}/.kobold"
14
+ puts "ERROR: Kobold file not found at '#{Dir.pwd}'"
15
+ return
16
+ end
17
+ settings = Kobold.read_config(Dir.pwd)
18
+
19
+ if Kobold::FORMAT_VERSION == settings["_kobold_config"]["format_version"]
20
+ # iterate over all dependencies
21
+ settings.each do |key, value|
22
+ if key[0] == '_'
23
+ next
24
+ end
25
+ repo_dir = "#{KOBOLD_DIR}/repo_cache/#{value['repo'].gsub('/', '-')}"
26
+
27
+ source_repo = nil;
28
+ # check if source exists
29
+ if !Dir.exist? "#{repo_dir}/source" # TODO: make this properly check for git repo
30
+ # if it doesnt, make it
31
+ FileUtils.mkdir_p "#{repo_dir}/source"
32
+ FileUtils.mkdir_p "#{repo_dir}/worktrees"
33
+ FileUtils.mkdir_p "#{repo_dir}/worktrees/branched"
34
+ FileUtils.mkdir_p "#{repo_dir}/worktrees/sha"
35
+ FileUtils.mkdir_p "#{repo_dir}/worktrees/labelled"
36
+ FileUtils.mkdir_p "#{repo_dir}/branches"
37
+ source_repo = clone_git_repo "#{value["source"]}/#{value['repo']}.git", "#{repo_dir}/source"
38
+ next
39
+ # TODO this may need to be reworked, might not fetch new branches that are required
40
+ # if they havent been invoked previously.
41
+ # works good enough for now :3
42
+ else
43
+ source_repo = Git.open("#{repo_dir}/source")
44
+ end
45
+
46
+ progress_bar = TTY::ProgressBar.new("[:bar] Fetching: #{value["source"]}/#{value['repo']}.git ", bar_format: :blade, total: nil, width: 45)
47
+
48
+ thread = Thread.new(abort_on_exception: true) do
49
+ source_repo.fetch(all: true)
50
+ end
51
+ progress_bar.start
52
+ while thread.status
53
+ progress_bar.advance
54
+ sleep 0.016
55
+ end
56
+ puts
57
+ #return thread.value
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
data/lib/Kobold/init.rb CHANGED
@@ -9,12 +9,28 @@ module Kobold
9
9
  # create empty file with current
10
10
  # file version in current dir
11
11
  def init
12
- kobold_config = TTY::Config.new
13
- kobold_config.filename = ".kobold"
14
- kobold_config.extname = ".ini"
15
- kobold_config.set "_kobold_config", "format_version", value: Kobold::FORMAT_VERSION
16
- kobold_config.write
17
- File.rename ".kobold.ini", ".kobold"
12
+ kobold_default = <<-EOS
13
+ [_kobold_config]
14
+ format_version = #{Kobold::FORMAT_VERSION}
15
+
16
+ ; must be unique, can be anything that doesnt start with underscore
17
+ ;[raylib-linux]
18
+ ;
19
+ ; required
20
+ ;repo = raysan5/raylib
21
+ ;source = https://github.com
22
+ ;
23
+ ; optional, remove slash at the end to rename the dir the repo is in
24
+ ;dir = external/linux-x64/
25
+ ;
26
+ ; one of these 2 is required
27
+ ;branch = something
28
+ ;commit = 'b8cd102'
29
+ ;
30
+ ; optional, makes unique trunk
31
+ ;label = linux-x64
32
+ EOS
33
+ File.write('.kobold', kobold_default)
18
34
  end
19
35
  end
20
36
  end
data/lib/Kobold/invoke.rb CHANGED
@@ -121,7 +121,17 @@ module Kobold
121
121
 
122
122
  worktree_path = "#{repo_dir}/worktrees/sha"
123
123
  _commit_val = value["commit"].to_s.delete_prefix('"').delete_suffix('"').delete_prefix("'").delete_suffix("'")
124
- worktree_sha = source_repo.object(_commit_val).sha;
124
+
125
+ worktree_sha ||= :scoped # make variable in this scope instead of begin rescue scope
126
+ begin
127
+ worktree_sha = source_repo.object(_commit_val).sha;
128
+ rescue Git::FailedError => error
129
+ puts 'ERROR: Most likely failed to find SHA.'
130
+ puts ' Try to run "kobold fetch" or make sure SHA is valid'
131
+ puts " Original Error: #{error.message}"
132
+ exit
133
+ end
134
+
125
135
  target_symlink = "#{worktree_path}/#{worktree_sha}"
126
136
  if !Dir.exist? target_symlink
127
137
  FileUtils.mkdir_p "#{worktree_path}"
@@ -134,8 +144,10 @@ module Kobold
134
144
 
135
145
  end
136
146
 
147
+ value['dir'] ||= './' # by default create in current dir if not specified
148
+
137
149
  # build the symlink
138
- if value["dir"].end_with? "/"
150
+ if value["dir"].end_with?("/")
139
151
  FileUtils.mkdir_p value["dir"]
140
152
  #puts "value: " + value["dir"] + key.split('/').last
141
153
  #puts !File.symlink?(value["dir"] + key.split('/').last)
@@ -155,7 +167,7 @@ module Kobold
155
167
  FileUtils.mkdir_p dir_components
156
168
  File.symlink(target_symlink, value["dir"]) if !File.symlink? value["dir"]
157
169
 
158
- symlink1 = File.symlink?(value["dir"] + ['repo'].split('/').last)
170
+ symlink1 = File.symlink?(value["dir"] + value['repo'].split('/').last)
159
171
  symlink2 = File.symlink? value["dir"]
160
172
 
161
173
  if !(symlink1 || symlink2)
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobold
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.4"
5
5
  FORMAT_VERSION = "0.3.0"
6
+ class << self
7
+ def version
8
+ puts "Kobold: #{Kobold::VERSION}"
9
+ puts "Kobold Format: #{Kobold::FORMAT_VERSION}"
10
+ end
11
+ end
6
12
  end
data/lib/Kobold.rb CHANGED
@@ -10,6 +10,7 @@ require_relative 'Kobold/read_config.rb'
10
10
  require_relative 'Kobold/first_time_setup.rb'
11
11
  require_relative 'Kobold/invoke.rb'
12
12
  require_relative 'Kobold/init.rb'
13
+ require_relative 'Kobold/fetch.rb'
13
14
 
14
15
  module Kobold
15
16
  KOBOLD_DIR = "#{Dir.home}/.local/share/Kobold"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Kobold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - CatsAtTheRodeo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-09 00:00:00.000000000 Z
11
+ date: 2023-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-option
@@ -102,6 +102,7 @@ files:
102
102
  - Rakefile
103
103
  - exe/kobold
104
104
  - lib/Kobold.rb
105
+ - lib/Kobold/fetch.rb
105
106
  - lib/Kobold/first_time_setup.rb
106
107
  - lib/Kobold/init.rb
107
108
  - lib/Kobold/invoke.rb