wakatime / sublime-wakatime

Sublime Text 2 & 3 plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/sublime-text
BSD 3-Clause "New" or "Revised" License
525 stars 47 forks source link

Unable to detect branch name (Subversion) #25

Closed blomqvist closed 9 years ago

blomqvist commented 9 years ago

Hi,

I have this problem where every branch I work in shows up as Unknown Project. I quickly looked at the plugin files, but could not see why it doesn't work.

The output of svn info in my branch (which follows typical JIRA-issue naming, in my case SNO2-XXX):

~/S/SNO2-151 $ svn info
Path: .
Working Copy Root Path: /Users/blomqvist/Sites/SNO2-151
URL: https://www.XYZ.com/repos/svn-XYZ2/branches/SNO2-151
Relative URL: ^/branches/SNO2-151
Repository Root: https://www.XYZ.com/repos/svn-XYZ2
Repository UUID: wasp
Revision: 456
Node Kind: directory
Schedule: normal
Last Changed Author: nblomqvist
Last Changed Rev: 456
Last Changed Date: 2014-08-25 16:43:43 +0200 (Mån, 25 Aug 2014)

Shouldn't it be able to extract the branch name from this info?

~/S/SNO2-151 $ which svn
/usr/local/bin/svn

/usr/local/bin is also the first row in /etc/paths

When I check my history from last year, I can see that it did recognize the project as well as the branches. (The project was sno-xx then, but everything else is the same regarding the svn repo). I have since reinstalled OS X and updated to a newer version of Subversion.

OS: OS X Mavericks Sublime Text 3

~/S/SNO2-151 $ svn --version
svn, version 1.8.10 (r1615264)
alanhamlett commented 9 years ago

Yes, it should be able to extract the project name from that svn info. I just tested with Subversion 1.8 and WakaTime was able to recognize the project. Which package manager did you use to install svn? fink, homebrew, macports, etc?

blomqvist commented 9 years ago

Hi!

I use homebrew.

~ $ brew info subversion
subversion: stable 1.8.10 (bottled)
https://subversion.apache.org/
/usr/local/Cellar/subversion/1.8.10 (116 files, 9,4M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/subversion.rb
==> Dependencies
Build: pkg-config ✘, autoconf ✔, automake ✘, libtool ✔, scons ✘
Required: sqlite ✔, openssl ✔
==> Options
--java
    Build Java bindings
--perl
    Build Perl bindings
--ruby
    Build Ruby bindings
--universal
    Build a universal binary
--with-python
    Build with python support
==> Caveats
svntools have been installed to:
  /usr/local/opt/subversion/libexec

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
~ $ which svn
/usr/local/bin/svn

When I see this.. I perhaps should use "brew install subversion --with-python"?

alanhamlett commented 9 years ago

Should work now with svn installed from homebrew. The svn binary wasn't being found in the Sublime Text version of python's PATH.

blomqvist commented 9 years ago

Hi! Sorry for very late feedback.

It does detect project names just fine now, but it seems as it won't detect the branch name. skarmavbild 2014-09-26 kl 12 34 52

This is the typical output of svn info.

~/S/SNO2-292 $ svn info
Path: .
Working Copy Root Path: /Users/blomqvist/Sites/SNO2-292
URL: https://www.XYZ.com/repos/svn-snosvangen2/branches/SNO2-292
Relative URL: ^/branches/SNO2-292
Repository Root: https://www.XYZ.com/repos/svn-snosvangen2
Repository UUID: cf3a2f34-b886-4c5b-a2b1-2dc034913b84
Revision: 921
Node Kind: directory
Schedule: normal
Last Changed Author: nblomqvist
Last Changed Rev: 921
Last Changed Date: 2014-09-25 14:32:39 +0200 (Tor, 25 Sep 2014)

~/S/SNO2-292 $ svn --version
svn, version 1.8.10 (r1615264)

I don't know if things might clash, but I also have Modific and Sublimerge installed.

alanhamlett commented 9 years ago

Ok, that's a problem with branching in SVN, since it doesn't support branches like other revision control software. Which convention do you use for branches in svn?

blomqvist commented 9 years ago

Oh, alright!

I use svn copy ^/trunk ^/branches/BRANCH-NAME on remote. As I always have the trunk checked out as, in this case, SNO2-trunk I run a script which copies (cp -r SNO2-trunk SNO2-branch) the trunk and run svn switch on the copy.

I got it work nice for me by changing branch() in subversion.py in the Sublime Wakatime plugin:

    def branch(self):
        if self.base:
            unicode(os.path.basename(self.base))
        return unicode(self.info['URL'].split('/')[-1])
blomqvist commented 9 years ago

@alanhamlett is my response above something that might be feasible, or is it breaking the use for others in some way? :)

alanhamlett commented 9 years ago

Since the old code was missing return, it would always return None so I think it's safe to just use your branching convention and not worry about breaking anything for existing users.

Version 2.0.15 of the Sublime plugin will get the branch name from the URL value.

blomqvist commented 9 years ago

@alanhamlett 100 units of kudos to you!