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 +4 -4
- data/exe/kobold +6 -0
- data/lib/Kobold/fetch.rb +62 -0
- data/lib/Kobold/init.rb +22 -6
- data/lib/Kobold/invoke.rb +15 -3
- data/lib/Kobold/version.rb +7 -1
- data/lib/Kobold.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3365a9b108ba3abccb20d4040f8f10c2b3cfeafaffcb1eab97f8bb6ec31c96f2
|
4
|
+
data.tar.gz: d5449335967f96c07777761a95a5de46b4a61857fd0c782b85dbfc8ab9ef7c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f41daea3213f01c72847b0cf4e51cc86580d1c514f3d89575273fb1f0437c720dce10bbc455c59ef8fa733eb59f433c78c2102cbd88856dab15ac4068422eb
|
7
|
+
data.tar.gz: 2e12df3ae02950f89743efe353855c86409073d5031af3eba41c8c1ab4e5d7dc18d85e3e3546fbcf05c799ceef49cb09b222b7877d86193d6c4d120c758f0281
|
data/exe/kobold
CHANGED
data/lib/Kobold/fetch.rb
ADDED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
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)
|
data/lib/Kobold/version.rb
CHANGED
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.
|
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-
|
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
|