label_weaver 0.0.10 → 0.0.12

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: 290288a3de5f82f2011f9dbd603e6b9f8ee369bb64ffdc77c544004f4dc6e5e8
4
- data.tar.gz: 9377d8b8a5a46c8630a9d0f3ba6e38189ff68dd1679b84cc6b4a2bdc1058c11a
3
+ metadata.gz: 05fe807fe77e2b113196ff90e2aaba53c75594a68d95c1164e304640836b7ba0
4
+ data.tar.gz: 95325968105011a5ab6a3252f6cc445c5e7df848114f2c456e4d15d93e913098
5
5
  SHA512:
6
- metadata.gz: 8b12f4ed0bb7cef83d3066680a623ba9d8ef03b67ea643b684ba985aee57e7d1502b573519d242942dc01f1af91a422c79ae605eada47d4510265c874924e9c8
7
- data.tar.gz: 1cf1ff573c45a3972e46dce59bca1f432aec28e7f275ce15c0dcd98401f0f75b54063aae5db24763339a275b0329eab77ae2b022e53fc6b09ed9b81a702282fd
6
+ metadata.gz: 9ac762eebf1ece654e3dd2ef6e37e8154d2e5a9794d999bfed55ae52a92b86b0066e333c209cac5c844d12e898aef172752bd36803ccefc609cae03ee2c7f58a
7
+ data.tar.gz: 1d2a7cace4b93d1d04939382f892d5442abe36861855926218c7682f62b5182007fea0b09910addb7ee427ab5d6a230b19b5ea3a608887bdc3a1fcaf920605b5
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.10"
5
+ spec.version = "0.0.12"
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)
@@ -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?
@@ -31,7 +31,7 @@ module LabelWeaver
31
31
  # @return [Time] the last time the file was part of a commit, closest we can get to an mtime
32
32
  #
33
33
  def timestamp_for(file)
34
- repo.log(1).path(file).first.date
34
+ git.log(1).path(file).first.date
35
35
  end
36
36
 
37
37
  def digest_for(file)
@@ -45,13 +45,19 @@ 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
- logger.info "Pulling latest changes from remote repository (#{repository_url})..."
55
+ logger.info "Pulling latest changes from remote repository (#{repository_url}##{branch})..."
51
56
 
52
- repo.pull("origin", branch)
57
+ git.fetch(all: true, force: true)
58
+ git.checkout(branch)
53
59
  else
54
- logger.info "Cloning remote repository, this might take a while..."
60
+ logger.info "Cloning remote repository (#{repository_url}##{branch}), this might take a while..."
55
61
 
56
62
  Git.clone(
57
63
  repository_url,
@@ -96,7 +102,7 @@ module LabelWeaver
96
102
  logger.info "Updating repository timestamps..."
97
103
  repository_path.glob("**/*", File::FNM_DOTMATCH).each do |file|
98
104
  # Set the file modification times to the last time they were updated in a commit
99
- time = repo.all.log.path(file).first.date
105
+ time = git.all.log.path(file).first.date
100
106
  file.utime(time, time)
101
107
  end
102
108
  end
@@ -130,8 +136,8 @@ module LabelWeaver
130
136
  repository_path.glob("**/*", File::FNM_DOTMATCH).select { _1.file? || _1.symlink? }
131
137
  end
132
138
 
133
- def repo
134
- @repo ||= Git.open(repository_path)
139
+ def git
140
+ @git ||= Git.open(repository_path)
135
141
  end
136
142
  end
137
143
  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.10
4
+ version: 0.0.12
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-13 00:00:00.000000000 Z
11
+ date: 2024-12-22 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