totten / git-scan

CLI tool for scanning/updating git repos
33 stars 7 forks source link

Failed to determine tracking branch #1

Closed splitbrain closed 10 years ago

splitbrain commented 10 years ago

Seems like it crashes when a repository has no upstream?

$ git scan -vvv status 
[[ Finding repositories ]]
[[ Checking statuses ]]
 4/5 [======================>-----]  80% Elapsed:  1 sec
Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to determine tracking branch' in phar:///home/gohr/Dropbox/bin/git-scan/src/GitScan/GitRepo.php on line 130

RuntimeException: Failed to determine tracking branch in phar:///home/gohr/Dropbox/bin/git-scan/src/GitScan/GitRepo.php on line 130

Call Stack:
    0.0001     228680   1. {main}() /home/gohr/Dropbox/bin/git-scan:0
    0.0031     293928   2. require('phar:///home/gohr/Dropbox/bin/git-scan/bin/git-scan') /home/gohr/Dropbox/bin/git-scan:10
    0.0057     612104   3. GitScan\Application::main() phar:///home/gohr/Dropbox/bin/git-scan/bin/git-scan:17
    0.0130    1502272   4. Symfony\Component\Console\Application->run() phar:///home/gohr/Dropbox/bin/git-scan/src/GitScan/Application.php:19
totten commented 10 years ago

Thanks for the error report. A few requests/thoughts:

  1. The relevant spot is https://github.com/totten/git-scan/blob/master/src/GitScan/GitRepo.php#L130
  2. Could you manually cd in to the repo and run "git rev-parse --abbrev-ref @{upstream}" then post the output? git-scan is expecting the output to match a regex ([a-zA-Z0-9_.\/]+), and the error indicates that the output is something different.
  3. It might also be helpful to show the output of "git --version"
  4. Are you familiar enough with PHP to run the phpunit tests? The tests go through a series of example operations (like creating a standalone repo; creating an upstream+downstream repo with related branches; etc and then checking the statuses for each). We could rule-out/rule-in some possible problems by running the test suite.
splitbrain commented 10 years ago

Let's start with the unit tests:

PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from /bulk/temp/2014-01-17/git-scan/phpunit.xml.dist

......EEEEEE.......FF............................

Time: 1 second, Memory: 7.75Mb

There were 6 errors:

1) GitScan\GitRepoTest::testLocalOnly_Empty
RuntimeException: Failed to determine tracking branch

/bulk/temp/2014-01-17/git-scan/src/GitScan/GitRepo.php:130
/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:11

2) GitScan\GitRepoTest::testLocalOnly_AllCommitted
RuntimeException: Failed to determine tracking branch

/bulk/temp/2014-01-17/git-scan/src/GitScan/GitRepo.php:130
/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:22

3) GitScan\GitRepoTest::testLocalOnly_ModifiedFile
RuntimeException: Failed to determine tracking branch

/bulk/temp/2014-01-17/git-scan/src/GitScan/GitRepo.php:130
/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:34

4) GitScan\GitRepoTest::testLocalOnly_NewFile
RuntimeException: Failed to determine tracking branch

/bulk/temp/2014-01-17/git-scan/src/GitScan/GitRepo.php:130
/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:46

5) GitScan\GitRepoTest::testLocalOnly_NewDir
RuntimeException: Failed to determine tracking branch

/bulk/temp/2014-01-17/git-scan/src/GitScan/GitRepo.php:130
/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:58

6) GitScan\GitRepoTest::testLocalOnly_NewAndModifiedFiles
RuntimeException: Failed to determine tracking branch

/bulk/temp/2014-01-17/git-scan/src/GitScan/GitRepo.php:130
/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:71

--

There were 2 failures:

1) GitScan\GitRepoTest::testIsFastForwardable_downstreamChanged
Failed asserting that true matches expected false.

/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:181

2) GitScan\GitRepoTest::testIsFastForwardable_bothChanged
Failed asserting that true matches expected false.

/bulk/temp/2014-01-17/git-scan/tests/GitScan/GitRepoTest.php:193

FAILURES!
Tests: 49, Assertions: 103, Failures: 2, Errors: 6.
splitbrain commented 10 years ago
$ git --version
git version 1.8.5.2
splitbrain commented 10 years ago

Okay, I found the repository that causes the trouble:

$ git rev-parse --abbrev-ref @{upstream}
fatal: No upstream configured for branch 'magnific'
$ git branch -a -vv
* magnific                   eb8ce1b updated magnific popup
  master                     1f87cc6 [origin/master] no longer rely on deprecated SimplePie function
  prettyphoto                7da7ab1 [origin/prettyphoto: ahead 1] Some style fixes
  remotes/origin/HEAD        -> origin/master
  remotes/origin/magnific    eb8ce1b updated magnific popup
  remotes/origin/master      1f87cc6 no longer rely on deprecated SimplePie function
  remotes/origin/prettyphoto 18fbf85 fixed javascript paging
totten commented 10 years ago

OK, I haven't been able to reproduce that exact error message, but I reproduced an error message which included that one, so I used that in crafting a patch (e5eb5d1). The patch is included in the new tag, 2014-01-19, and the new phar download.

Let me know if it helps.

splitbrain commented 10 years ago

Yep, can confirm this fixes the problem for me.