Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reading git last commit #28

Merged
merged 1 commit into from
Aug 22, 2016

Conversation

jgrzebyta
Copy link
Contributor

I have added a support for reading git last commit:

semver-git returns full number of the last commit as string
semver-short-git returns only 5 first characters from the number.

@burn2delete
Copy link
Member

I wonder if there is a better name we can give these functions? It would be cool if we could also pass an index to the commands to fetch a commit from further back in the history.

@burn2delete burn2delete mentioned this pull request Jun 21, 2016
5 tasks
@arichiardi
Copy link
Contributor

This is great! 👍

@burn2delete
Copy link
Member

This will be worked on as part of boot-semgit which will provide semantic access to git from boot.

@arichiardi
Copy link
Contributor

That's great, will we have two separate tasks? I like the boot version --switch approach.

@burn2delete
Copy link
Member

Yes, another task will be provided for interacting with git, it will also provide things like creating feature and version branches

@arichiardi
Copy link
Contributor

It is also a nice idea to get a -z number from the git commit "height". Like Clojurescript.

@burn2delete burn2delete merged commit 7aaa270 into degree9:master Aug 22, 2016
@burn2delete
Copy link
Member

Agreed, added to keep dependencies low.

@burn2delete
Copy link
Member

@arichiardi @jgrzebyta version 1.3.1 pushed to clojars

@arichiardi
Copy link
Contributor

arichiardi commented Aug 23, 2016

$ boot -P version -b semver-git
Version in version.properties ...: 0.1.3
Current Build Version ...: 0.1.3+212126773a789c9446422c49985909cd5c225e59
Updating Project Version...: 0.1.3->0.1.3+212126773a789c9446422c49985909cd5c225e5

but then:

boot -P version -b semver-short-git or boot -P version -b empty -r semver-git or boot -P version -r semver-short-git

     clojure.lang.ExceptionInfo: Invalid number: 212126773a789c9446422c49985909cd5c225e59
    data: {:file "/tmp/boot.user7157696358893909333.clj", :line 67}
java.lang.NumberFormatException: Invalid number: 212126773a789c9446422c49985909cd5c225e59
                                         ...                
       clojure.core/read-string/invokeStatic  core.clj: 3768
                    clojure.core/read-string  core.clj: 3758
          boot-semver.core/update-version/fn  core.clj:   57
         clojure.core/merge-with/merge-entry  core.clj: 3035
           clojure.core/reduce1/invokeStatic  core.clj:  936
              clojure.core/merge-with/merge2  core.clj: 3038
           clojure.core/reduce1/invokeStatic  core.clj:  936
           clojure.core/reduce1/invokeStatic  core.clj:  926
        clojure.core/merge-with/invokeStatic  core.clj: 3031
                     clojure.core/merge-with  core.clj: 3023
                                         ...                
boot-semver.core/update-version/invokeStatic  core.clj:   53
             boot-semver.core/update-version  core.clj:   51
                boot-semver.core/eval1512/fn  core.clj:   99
                                         ...                
             clojure.core/apply/invokeStatic  core.clj:  657
                          clojure.core/apply  core.clj:  652
                   boot.core/construct-tasks  core.clj:  911
                                         ...                
             clojure.core/apply/invokeStatic  core.clj:  657
                          clojure.core/apply  core.clj:  652
                           boot.core/boot/fn  core.clj:  949
         clojure.core/binding-conveyor-fn/fn  core.clj: 2019

@burn2delete
Copy link
Member

@arichiardi could you try this again? Here is my test:

matt-mbpr:boot-semver matt$ boot version
Version in version.properties ...: 1.3.2
Current Build Version ...: 1.3.2

matt-mbpr:boot-semver matt$ boot -P version -b semver-git
Version in version.properties ...: 1.3.2
Current Build Version ...: 1.3.2+cf161fa763daced28cfa21301a0c3b0febd7b1dc
Updating Project Version...: 1.3.2->1.3.2+cf161fa763daced28cfa21301a0c3b0febd7b1dc

matt-mbpr:boot-semver matt$ boot -P version -b empty -r semver-git
Version in version.properties ...: 1.3.2+cf161fa763daced28cfa21301a0c3b0febd7b1dc
Current Build Version ...: 1.3.2-cf161fa763daced28cfa21301a0c3b0febd7b1dc
Updating Project Version...: 1.3.2+cf161fa763daced28cfa21301a0c3b0febd7b1dc->1.3.2-cf161fa763daced28cfa21301a0c3b0febd7b1dc

@arichiardi
Copy link
Contributor

uhm yeah, here it does not work @flyboarder weird...I am using 1.3.2 with clojure 1.9.0-alpha10

@burn2delete
Copy link
Member

@arichiardi could you try a version of clojure 1.8 or 1.7?

@arichiardi
Copy link
Contributor

Tried, now working, it looks like the conversion of read-string is failing after the strip, very weird that it works over there and here it does not...

@burn2delete
Copy link
Member

@arichiardi I found the issue, if git commit id starts with a digit the entire string is assumed a number, if it starts with a letter the string is a correct string.

@arichiardi
Copy link
Contributor

Oh wow, here is something I did not know about the reader, maybe it is some sort of optimization.

@burn2delete
Copy link
Member

@arichiardi Yeah I didnt know that either. I am pushing 1.3.3, which uses clojure.string/replace and removes read-string

@arichiardi
Copy link
Contributor

Confirm it is working fine now

@burn2delete
Copy link
Member

This will however break inc for build and release versions.

From: Andrea Richiardi notifications@github.com
Reply-To: degree9/boot-semver reply@reply.github.com
Date: Monday, August 22, 2016 at 7:15 PM
To: degree9/boot-semver boot-semver@noreply.github.com
Cc: matt matt@degree9.io, Mention mention@noreply.github.com
Subject: Re: [degree9/boot-semver] Add support for reading git last commit (#28)

Confirm it is working fine now


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//pull/28#issuecomment-241598972, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAI-PIJgAyF1DSeGvmyPmkq67-n-X51eks5qikmXgaJpZM4I6rTW.

@arichiardi
Copy link
Contributor

Oh I was using them more then git 😄 ...we can maybe put a if in there?

@burn2delete
Copy link
Member

@arichiardi Can you give 1.3.4 a try, this should fix all the things 😹

@arichiardi
Copy link
Contributor

arichiardi commented Aug 23, 2016

yep!

😄

$ boot -P version -b semver-short-git
     clojure.lang.ExceptionInfo: Invalid number: 408e34ad453aad1654933610002a74f3fa5b072f
    data: {:file "/tmp/boot.user8538587128119435771.clj", :line 67}
java.lang.NumberFormatException: Invalid number: 408e34ad453aad1654933610002a74f3fa5b072f
                                         ...                
       clojure.core/read-string/invokeStatic  core.clj: 3768
                    clojure.core/read-string  core.clj: 3758
      boot-semver.core/str->num/invokeStatic  core.clj:   51
                   boot-semver.core/str->num  core.clj:   50
          boot-semver.core/update-version/fn  core.clj:   61
         clojure.core/merge-with/merge-entry  core.clj: 3035
           clojure.core/reduce1/invokeStatic  core.clj:  936

@burn2delete
Copy link
Member

burn2delete commented Aug 23, 2016

Ok one last try 😸 1.3.5 on clojars.

@burn2delete
Copy link
Member

@arichiardi ^

@arichiardi
Copy link
Contributor

arichiardi commented Aug 23, 2016

Works! but I have a question 😃 below

Version in version.properties ...: 0.1.3
Current Build Version ...: 0.1.3-408e3
Updating Project Version...: 0.1.3->0.1.3-408e3 <- why is this just 5 chars instead of the classic 7?

$ boot -P version -r empty -b semver-git
Version in version.properties ...: 0.1.3-408e3
Current Build Version ...: 0.1.3+408e34ad453aad1654933610002a74f3fa5b072f
Updating Project Version...: 0.1.3-408e3->0.1.3+408e34ad453aad1654933610002a74f3fa5b072f

kapitan@sea:~/git/booma (improve-error-persistence *$%)$ boot -P version -r empty -b empty
Version in version.properties ...: 0.1.3+408e34ad453aad1654933610002a74f3fa5b072f
Current Build Version ...: 0.1.3
Updating Project Version...: 0.1.3+408e34ad453aad1654933610002a74f3fa5b072f->0.1.3

$ boot -P version -r inc
Version in version.properties ...: 0.1.3
Current Build Version ...: 0.1.3-1
Updating Project Version...: 0.1.3->0.1.3-1

$ boot -P version -b inc 
Version in version.properties ...: 0.1.3-1
Current Build Version ...: 0.1.3-1+1
Updating Project Version...: 0.1.3-1->0.1.3-1+1

@burn2delete
Copy link
Member

@arichiardi This PR only selected the first 5 chars. I will fix for version 1.4.0 with the generated namespace changes.

@arichiardi
Copy link
Contributor

Ok fair enough, I just thought it was a bug as usually you need 7, but I don't know what is the actual usage of it in the wild. Also, git chose 7 because it does not clash I guess. Anyways I am fine with this for now, thanks a lot for the bug fixing 👍

@burn2delete
Copy link
Member

@arichiardi Thanks for all the awesome testing! Helps so much! 😺

@burn2delete burn2delete self-assigned this Aug 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants