Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-03 18:48:19

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Show svnversion in txp:php or txp:variable

How can I show the output of svnversion for my project in Textpattern?

I want to post a comment to show the current version of the entire project (as displayed by the svnversion command in the shell). Maybe something like this:

<!--
version: <txp:variable name="svnversion"/>
-->

Is there any way I can set it as a variable or display it using php?

Thanks!

Last edited by johnstephens (2009-08-03 18:50:39)

Offline

#2 2009-08-03 19:19:06

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Show svnversion in txp:php or txp:variable

From what I can tell you’d have to add some functionality to your deployment process to provide this data.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2009-08-03 20:24:23

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Show svnversion in txp:php or txp:variable

There is mkp_version, a very small plugin. The download link in the thread is broken but I can send it to you if you want.

Offline

#4 2009-08-03 21:15:53

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Show svnversion in txp:php or txp:variable

Els wrote:

There is mkp_version, a very small plugin. The download link in the thread is broken but I can send it to you if you want.

Thanks— I found it at archive.org. This plugin seems to work like mg_txpversion —posting the current version of Textpattern.

What I’m looking for is a way to publish the current revision of my project, based on the output of an svnversion command.

@MattD: Thanks, I saw that thread on stackoverflow, but I’m afraid it went over my head. I can see caching the current version to a file by manually entering the recommended commands, and I can see pulling them into my template with <txp:php>include 'version.php';</txp:php>, but I don’t know how to automate the cached version info. I thought there might be a php way to get it, but it might be a castle in the air.

Thanks again for helping me think it through. let me know if you get any ideas.

Last edited by johnstephens (2009-08-03 21:18:07)

Offline

#5 2009-08-03 21:24:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: Show svnversion in txp:php or txp:variable

johnstephens wrote:

a way to publish the current revision of my project, based on the output of an svnversion command.

Well if you can’t run svnversion directly on your host inside some one-line plugin (PHP’s exec() or passthru() functions?), you could try looking in txp_diag.php.

From line 270 onwards is a section that determines the highest revision from all the files in the repository. It works by iterating over each file and extracting the LastChangedRevision string then stashing the highest number it finds. Messy, but it works if you have a list of all files in your project or can iterate over the entire directory tree using glob(). The code there might give you some ideas.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2009-08-03 21:39:47

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Show svnversion in txp:php or txp:variable

johnstephens wrote:

a way to publish the current revision of my project, based on the output of an svnversion command.

The plugin does have a tag to display the revision as well…

Offline

#7 2009-08-03 22:12:13

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Show svnversion in txp:php or txp:variable

Textpattern revision and svnversion are not the same.

<txp:php>echo exec(svnversion);</txp:php>

Gives me 2966:3215M while my diagnostics page shows Textpattern version: 4.0.8 (r3215). Successful results probably vary by host.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#8 2009-08-03 23:10:57

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Show svnversion in txp:php or txp:variable

<txp:php>echo exec(svnversion);</txp:php>

This displays exactly what I want on my publish server. Oddly, it outputs nothing at all on my dev server— even though <txp:php>echo exec(whoami);</txp:php> works fine. Problem solved, I guess.

The problem with mkp_version’s revision output is that it derives the revision info from Textpattern’s files, not from the subversion info of my project.

It would be nice to know why <txp:php>echo exec(svnversion);</txp:php> displays nothing on my dev server (so does <?php echo exec(svnversion); ?> in a plain php file, when whoami works as expected, but that mystery won’t intrude on my work.

Thanks again!

Offline

#9 2009-08-03 23:49:18

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Show svnversion in txp:php or txp:variable

So…

$ php -r 'echo shell_exec("svnversion");'

outputs nothing? (svnversion needs to be quoted too, since it’s not a constant.)

Check your PATH too:

$ type -p svnversion # where svnversion is located
# compare this:
$ echo $PATH
# to:
$ php -r "echo shell_exec('echo $PATH')'

Last edited by jm (2009-08-03 23:49:44)

Offline

#10 2009-08-04 00:21:09

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Show svnversion in txp:php or txp:variable

Thank, Jon-Michael. I’m not sure if my findings are helpful, but here they are:

$ php -r 'echo shell_exec("svnversion");'

exported

$ type -p svnversion # where svnversion is located

/usr/bin/svnversion

# compare this:
$ echo $PATH
# to:
$ php -r "echo shell_exec('echo $PATH');"

Both paths are identical, both include /usr/bin.

Offline

#11 2009-08-04 00:32:13

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Show svnversion in txp:php or txp:variable

Weird. What about trying shell_exec("/usr/bin/svnversion");? Also, what version of PHP are you running on your devel-server? Leopard’s default?

Offline

#12 2009-08-04 04:11:49

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Show svnversion in txp:php or txp:variable

johnstephens wrote:

$ php -r 'echo shell_exec("svnversion");'

If invoked on a directory that is not a working copy, svnversion assumes it is an exported working copy and prints "exported"


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

Board footer

Powered by FluxBB