Kobold 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b01ef45723db1d81362231eaf2c96f48c4100417815c857ff7081e5afaca6a7
4
- data.tar.gz: df39075df665002608e5c6d2dfe197ca4430eee17710f25f3bd6d3ef10089f94
3
+ metadata.gz: 3365a9b108ba3abccb20d4040f8f10c2b3cfeafaffcb1eab97f8bb6ec31c96f2
4
+ data.tar.gz: d5449335967f96c07777761a95a5de46b4a61857fd0c782b85dbfc8ab9ef7c20
5
5
  SHA512:
6
- metadata.gz: 9f95193cfad4df42f9a60c85067d877ebf94feefe076e88e6fe01615e017d552184fa635f82e59f0226b6aad1d5355ec826caf78090a614ebc47f8f0fcc78d24
7
- data.tar.gz: 5aae8bb42f77bf81d728fad33f36ae38ca3c896611a5cda3b78cb386f196bce3f48134c6de6393ba250baee1870c974bebbbe44768e02915bc2d063ef675bd53
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)
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobold
4
- VERSION = "0.3.3"
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.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-10 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