Skip to content

Instantly share code, notes, and snippets.

@superstructor
Last active December 30, 2019 04:26
Show Gist options
  • Select an option

  • Save superstructor/fd5b8b21e910cbbc384330d28e722e1d to your computer and use it in GitHub Desktop.

Select an option

Save superstructor/fd5b8b21e910cbbc384330d28e722e1d to your computer and use it in GitHub Desktop.
lein-git-inject.md
  ;; left matched against [ "v0.0.4" ahead? dirty? ]
  ;; right matched against git describe --tags output "v0.0.4-5-ge2028de"
  :lein-git-inject {[#"v\d+\.\d+\.\d+" false? (constantly true)] #"v(\d+\.\d+\.\d+).*"
                    [#"v\d+\.\d+\.\d+" true?  (constantly true)] [#"v(\d+\.\d+\.\d+-\d+-[a-z0-9][8])" "-SNAPSHOT"]}

  ;; same but with static values instead of fns
  ;; except there is an issue with using `_` which is idiomatic syntax as we cannot write as a macro and:
  ;; WARNING: Can't take value of macro cljs.core/_ at line..
  :lein-git-inject-2 {[#"v\d+\.\d+\.\d+" false _] #"v(\d+\.\d+\.\d+).*"
                      [#"v\d+\.\d+\.\d+" true  _] [#"v(\d+\.\d+\.\d+-\d+-[a-z0-9][8])" "-SNAPSHOT"]}


  ;; simpler right side by providing git describe --tags output "v0.0.4-5-ge2028de" as
  ;; %semver v0.0.4
  ;; %ahead 5
  ;; %hash ge2028de
  :lein-git-inject-3 {[#"v\d+\.\d+\.\d+" false _] "%semver"
                      [#"v\d+\.\d+\.\d+" true  _] "%semver-%ahead-%hash-SNAPSHOT"}