Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

Open in Trac Browser #19

Open
simonwheatley opened this issue Sep 28, 2011 · 5 comments
Open

Open in Trac Browser #19

simonwheatley opened this issue Sep 28, 2011 · 5 comments

Comments

@simonwheatley
Copy link
Contributor

One useful feature of WordPress' Trac instance is browsing a nice, syntax highlighted copy of the code. I find it handy to link to things during IRC and IM conversations, and in emails. I've written a command which opens the current file and line number in Trac. For example, here's a link to the wp_update_post function in Trac:

http://core.trac.wordpress.org/browser/trunk//wp-includes/post.php#L2651

The commit for the command is here:

simonwheatley@4fd1b9c

Some questions, if you have a moment:

  • The command currently assumes that your TM_PROJECT_DIRECTORY is equivalent to WordPress' root dir – is there any way I can read the Path to WordPress preference into my command?
  • The command currently opens the file in Trunk, and sometimes functions have moved – is there any variable set anywhere in the bundle to indicate the current version of WordPress so the command can target the appropriate tag?

Cheers,

Simon

@Gipetto
Copy link
Owner

Gipetto commented Sep 28, 2011

You might try doing something with filesystem discovery. Basically, look at the current file's directory and keep going up a level until you find wp-config-sample.php and then from there go after the /wp-includes/version.php file to extract the version number. That's pretty much the best way I can think of to get the version of the current code base that you're looking at.

@simonwheatley
Copy link
Contributor Author

Thanks for the pointers. I've made some amends, done some painful rebasing (had to redo that SO many times and fix so many versions of the same conflict) and here's the combined commit… I think it's ready for you, if you're interested:

simonwheatley@382ee2e

I'm now using Spotlight to find the version.php file and then use regexes to find the WP version, and some simple search/replace logic to establish what the WordPress directory is.

@Gipetto
Copy link
Owner

Gipetto commented Sep 29, 2011

I love it!

The only thing that I don't like is that it only works in the scope of a project. I think we should have a (slower) fallback that figures out where it is in relation to the wp-root and uses that in the mdfind command.

@simonwheatley
Copy link
Contributor Author

So if you've opened a single file, the script recurses down the directories until it finds wp-load.php (more reliable than wp-config.php aswp-config.php can be outside the WP, and document, root) and then uses that as the starting point?

@Gipetto
Copy link
Owner

Gipetto commented Sep 29, 2011

Yeah, I think that'd do it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants