label_weaver 0.0.9 → 0.0.11

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: e80b3c26d499a033afc34ecd7fb14173b01037e7cd438870ec3e8287f4bb82c8
4
- data.tar.gz: dd696f8f74079db3333e1be27d141733a2b01129ba4db5f897ced196150b8b4b
3
+ metadata.gz: c0e81d732a25f3c7ed75a3c975633aefcefe0ba5b0c6c33fbb2565d31469e3f4
4
+ data.tar.gz: c90c1d33620e1b5c76aac616db225c431fe350f0a2a7cd935a6e77d29b6e4af9
5
5
  SHA512:
6
- metadata.gz: 5fbf1d2d15c9f10fbc08731d735485bda5d3c3fef8dc8f346e5f585612ba8b5b4d0a34078eb6b531fdc4e0b9e528a00dd19efe3fe902f233bc434a51b59ccfe4
7
- data.tar.gz: 40e6d0bf6cf2d5ae2052bae1b80460a9d8a10fe23d6a5a884bcab4059eadff113b2403174abf994bb3707297a36a2700a03bb0958c46f59d11fd76f6fb66de70
6
+ metadata.gz: 02ebb42b5c87d1ad2e4a5eeadb0d7baf731566144f0296b853345fbe83d292083fa5b1ff7f63ac07a9538bca53bf247aa0732d7f3306a92153382a8c0ae956c7
7
+ data.tar.gz: 78c68d51a19bfc52cc16993bf02b758f5759027f90044d066818a742c541bf45cc7106b0563b0365ff54ee8d6effa2daafa2acbb3ab110b2166037bb408df11c
data/label_weaver.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "label_weaver"
5
- spec.version = "0.0.9"
5
+ spec.version = "0.0.11"
6
6
  spec.authors = ["Stefan Exner"]
7
7
  spec.email = ["stex@stex.codes"]
8
8
  spec.homepage = "https://gitlab.com/lopo-tech/label_weaver"
@@ -23,7 +23,7 @@ module LabelWeaver
23
23
  end
24
24
 
25
25
  Hooks.new.run(:develop, :before_start)
26
- repo.clone_or_update
26
+ repo.clone_or_update(always_clone: configuration.always_clone)
27
27
  copy_repository_files
28
28
  handle_file_merges
29
29
  Hooks.new.run(:develop, :after_start)
@@ -42,8 +42,8 @@ module LabelWeaver
42
42
  # If the file is forced, we need to delete the existing file if it exists.
43
43
  FileUtils.rm_f(project_file) if project_file.exist?
44
44
  elsif Util.file_exists?(project_file)
45
- if repo.timestamp_for(repository_file) > project_file.mtime
46
- logger.warn "File '#{relative_filename}' has a newer version in the remote repository (#{repo.timestamp_for(repository_file)} vs #{project_file.mtime})."
45
+ if repo.timestamp_for(repository_file) > Util.mtime(project_file)
46
+ logger.warn "File '#{relative_filename}' has a newer version in the remote repository (#{repo.timestamp_for(repository_file)} vs #{Util.mtime(project_file)})."
47
47
  end
48
48
 
49
49
  logger.debug "Skipping '#{relative_filename}'..."
@@ -43,7 +43,7 @@ module LabelWeaver
43
43
  remove_empty_tree(project_file.dirname)
44
44
  elsif Util.file_exists?(project_file)
45
45
  if Util.digest(project_file) != Util.digest(repository_file)
46
- logger.debug "File '#{relative_filename}' is kept as it was changed in the whitelabel project (r: #{repo.timestamp_for(repository_file)} vs w: #{project_file.mtime})."
46
+ logger.debug "File '#{relative_filename}' is kept as it was changed in the whitelabel project (r: #{repo.timestamp_for(repository_file)} vs w: #{Util.mtime(project_file)})."
47
47
  else
48
48
  logger.debug "Deleting file '#{relative_filename}'..."
49
49
  project_file.unlink
@@ -0,0 +1,17 @@
1
+ module LabelWeaver
2
+ module CLI
3
+ module Actions
4
+ class PrintConfiguration < Sod::Action
5
+ include Import[:logger, :configuration]
6
+
7
+ on "--print-configuration"
8
+
9
+ description "Prints out the currently active configuration after evaluation"
10
+
11
+ def call(*)
12
+ puts JSON.pretty_generate(configuration.to_h)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -26,6 +26,7 @@ module LabelWeaver
26
26
  dsl.new :label_weaver, banner: specification.banner do
27
27
  on(::LabelWeaver::CLI::Actions::Init, context:)
28
28
  on(::LabelWeaver::CLI::Actions::PrepareBaseProject, context:)
29
+ on(::LabelWeaver::CLI::Actions::PrintConfiguration, context:)
29
30
  on(::LabelWeaver::CLI::Commands::Develop, context:)
30
31
  on(::LabelWeaver::CLI::Commands::Diff, context:)
31
32
  on(Sod::Prefabs::Actions::Version, context:)
@@ -9,6 +9,7 @@ module LabelWeaver
9
9
  required(:repository).filled(:string)
10
10
  required(:branch).filled(:string)
11
11
  end
12
+ optional(:always_clone).filled(:bool)
12
13
  optional(:excluded_upstream_files).array(:string)
13
14
  optional(:forced_upstream_files).array(:string)
14
15
  optional(:hooks).hash do
@@ -1,7 +1,18 @@
1
+ # This is the main configuration file for label_weaver in your project.
2
+ # It is parsed as ERb, feel free to use e.g. environment variables like
3
+ # "<%= ENV['BRANCH_NAME'] %>" or conditionals.
4
+ # The result still has to be valid YAML though.
5
+
1
6
  git:
2
7
  repository: "git@gitlab.com:lopo-tech/label_weaver.git"
3
8
  branch: "main"
4
9
 
10
+ # If set to +true+, the upstream repository is always cloned
11
+ # instead of the newest changes being pulled for an already cloned repository.
12
+ # This is useful if you change the upstream branch a lot and want to make
13
+ # sure you always have a clean state.
14
+ # always_clone: false
15
+
5
16
  # Files to exclude from the upstream repository, they will not be copied over to the whitelabel project.
6
17
  # Shell filename globbing rules apply, not regular expressions
7
18
  #excluded_upstream_files:
@@ -4,13 +4,14 @@ module LabelWeaver
4
4
  module Configuration
5
5
  # Defines the configuration model for use throughout the gem.
6
6
  Model = Data.define(
7
+ :always_clone,
7
8
  :excluded_upstream_files,
8
9
  :git,
9
10
  :hooks,
10
11
  :merges,
11
12
  :forced_upstream_files
12
13
  ) do
13
- def initialize(git:, hooks: {}, excluded_upstream_files: [], forced_upstream_files: [], merges: [])
14
+ def initialize(git:, always_clone: false, hooks: {}, excluded_upstream_files: [], forced_upstream_files: [], merges: [])
14
15
  super
15
16
  end
16
17
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "erb"
3
4
  require "cogger"
4
5
  require "containable"
5
6
  require "runcom"
@@ -12,7 +13,10 @@ module LabelWeaver
12
13
 
13
14
  register :configuration do
14
15
  if self[:xdg_config].active
15
- data = self[:defaults].merge(YAML.load_file(self[:xdg_config].active, symbolize_names: true))
16
+ configuration_file = File.read(self[:xdg_config].active)
17
+ config = ERB.new(configuration_file).result
18
+
19
+ data = self[:defaults].merge(YAML.load(config, symbolize_names: true))
16
20
  contract = Configuration::Contract.call(**data)
17
21
 
18
22
  raise ArgumentError.new(contract.errors.to_h) if contract.failure?
@@ -45,7 +45,12 @@ module LabelWeaver
45
45
  #
46
46
  # Clones the repository if it doesn't exist yet locally or fetches the latest updates
47
47
  #
48
- def clone_or_update
48
+ def clone_or_update(always_clone: false)
49
+ if always_clone
50
+ logger.info "Set to always clone the repository. Deleting any previously checked out version..."
51
+ FileUtils.rm_rf(repository_path)
52
+ end
53
+
49
54
  if repository_path.exist?
50
55
  logger.info "Pulling latest changes from remote repository (#{repository_url})..."
51
56
 
@@ -14,5 +14,14 @@ module LabelWeaver
14
14
  file.symlink? || file.exist?
15
15
  end
16
16
  module_function :file_exists?
17
+
18
+ def mtime(file)
19
+ if file.symlink? && !file.exist?
20
+ 0
21
+ else
22
+ file.mtime
23
+ end
24
+ end
25
+ module_function :mtime
17
26
  end
18
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: label_weaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Exner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-12 00:00:00.000000000 Z
11
+ date: 2024-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cogger
@@ -239,6 +239,7 @@ files:
239
239
  - lib/label_weaver/cli/actions/diff/format.rb
240
240
  - lib/label_weaver/cli/actions/init.rb
241
241
  - lib/label_weaver/cli/actions/prepare_base_project.rb
242
+ - lib/label_weaver/cli/actions/print_configuration.rb
242
243
  - lib/label_weaver/cli/commands/develop.rb
243
244
  - lib/label_weaver/cli/commands/diff.rb
244
245
  - lib/label_weaver/cli/shell.rb