Re: [Lazarus] How do you guys extract an SVN revision number from a Git commit ref?

2015-03-26 Thread Graeme Geldenhuys
On 2015-03-26 05:47, vfclists . wrote:
 This is what I have settled on in the mean time.
 
 LAZ_SVN_REVISION=`git log  | grep -A 10 $LAZ_GIT_REVISION | grep
 git-svn-id |  cut -d @ -f 2 | cut -d   -f 1`

Didn't the following work for you? It extracts exactly what you want and
will work on any commit, no matter how long the commit message, and only
uses built-in git functionality.

  git svn find-rev $(git log --max-count 1 --pretty=format:%H)

The find-rev needs a SHA1 value, which is what the second part of the
command (in brackets) does. So if the above command doesn't work in your
script as one command, simply split it into two.

  SHA1 = `git log --max-count 1 --pretty=format:%H`
  REVISION = `git svn find-rev $SHA1`

Or something like that.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How do you guys extract an SVN revision number from a Git commit ref?

2015-03-26 Thread JuuS


On 03/24/2015 10:10 PM, vfclists . wrote:
 
 I am using this code to obtain the SVN revision of a git commit hash.
 The example below is for the latest commit hence the git log -n 1.
 
 git log -n 1 | head -n 7 | tail -n 1 | cut -d @ -f 2 | cut -d   -f 1
 
 It checks for the seventh line, searches for the '@' in trunk@N and
 extracts it from there.
 The problem is the position the line with the trunk@N string varies.
 Is there some way to work it calculate it?
 
 My awk, grep and sed skills are not so hot.

I don't know if you live in the Linux world but if so there is a
software available in the Software Center called Kiki.

It's used to build and test Regular Expressions, and is a learning area
with a pretty good syntax explanations to try out and get used to.

HTH.


 
 -- 
 Frank Church
 
 ===
 http://devblog.brahmancreations.com
 
 
 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
 

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How do you guys extract an SVN revision number from a Git commit ref?

2015-03-26 Thread vfclists .
On 26 March 2015 at 10:58, Graeme Geldenhuys mailingli...@geldenhuys.co.uk
wrote:

 On 2015-03-26 10:42, vfclists . wrote:
  'git svn find-rev' works for finding the Git commit refs from subversion
  refs only if the subversion refs are of the form rN, and I thought
  going the other way

 Sorry, I probably haven't had enough coffee yet, but I don't fully
 understand. I thought you wanted the latest svn revision number by using
 a git mirror (of a subversion repo). That is exactly what the command
 does that I posted.

 For example. Here is the last commit I have in my lazarus repo (cloned
 from the git mirror on Github).
 ===
 $ git log -1
 commit d7e9b24c9bb114264663cc45d7148a4ade3f2b24
 Author: dmitry dmitry@4005530d-fff6-0310-9dd1-cebe43e6787f
 Date:   Thu Mar 26 00:48:36 2015 +

 printer4lazarus: carbon - replace OSX 10.5 (driver specific) code
 with OSX 10.0 compatible code for getting printerinters DPI

 git-svn-id: http://svn.freepascal.org/svn/lazarus/trunk@48507
 4005530d-fff6-0310-9dd1-cebe43e6787f
 ===


 As far as I understood, you are interested in finding the SVN revision
 of that commit - which is r48507 (by looking at the git-svn-id line.


 ===
 $ git svn find-rev $(git log --max-count 1 --pretty=format:%H)
 48507
 ===

 As you can see, the command returns exactly that revision for you.


 The first time you run the 'git svn find-rev' git will do some layout
 migration (svn info) for you. Maybe it is also because I'm using the
 very latest Git. But after the first run, it will always only return the
 svn revision number.


Your original answer was correct. I needed something for any commit not
just the latest, but the example I used was for just the latest commit, and
I confused myself as a result.

-- 
Frank Church

===
http://devblog.brahmancreations.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How do you guys extract an SVN revision number from a Git commit ref?

2015-03-25 Thread vfclists .
On 24 March 2015 at 23:33, Graeme Geldenhuys mailingli...@geldenhuys.co.uk
wrote:

 On 2015-03-24 21:10, vfclists . wrote:
 
  git log -n 1 | head -n 7 | tail -n 1 | cut -d @ -f 2 | cut -d   -f 1


 Try:

   git svn find-rev $(git log --max-count 1 --pretty=format:%H)


 Alternatively you could do something like this:

   git log -n 1 -z | grep trunk@[0-9]* 

 Tweak the regex to use lookbehind which could then trim the trunk@
 prefix. I don't know the regex syntax for grep. The following regex does
 the trick in my editor of choice, but not in the command above for some
 reason.

   (?=trunk@)[0-9]+



 Regards,
   - Graeme -



This is what I have settled on in the mean time.

LAZ_SVN_REVISION=`git log  | grep -A 10 $LAZ_GIT_REVISION | grep git-svn-id
|  cut -d @ -f 2 | cut -d   -f 1`

It searches the commit log for the 10 lines after the git commit ref ,
looks for the line saying git-svn-id and gets the part after the '@' at
sign. It needs more refinement though.

-- 
Frank Church

===
http://devblog.brahmancreations.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] How do you guys extract an SVN revision number from a Git commit ref?

2015-03-24 Thread vfclists .
I am using this code to obtain the SVN revision of a git commit hash. The
example below is for the latest commit hence the git log -n 1.

git log -n 1 | head -n 7 | tail -n 1 | cut -d @ -f 2 | cut -d   -f 1

It checks for the seventh line, searches for the '@' in trunk@N and
extracts it from there.
The problem is the position the line with the trunk@N string varies. Is
there some way to work it calculate it?

My awk, grep and sed skills are not so hot.

-- 
Frank Church

===
http://devblog.brahmancreations.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus