commit/mtrack: wez: need to "git push origin master" to persuade git to push into our freshly

10 views
Skip to first unread message

Bitbucket

unread,
Apr 29, 2012, 9:55:00 AM4/29/12
to mtr...@googlegroups.com
1 new commit in mtrack:


https://bitbucket.org/wez/mtrack/changeset/4b22c77f1c44/
changeset: 4b22c77f1c44
user: wez
date: 2012-04-29 15:49:18
summary: need to "git push origin master" to persuade git to push into our freshly
initialized git repos, or the below can happen.

Also put in some code to normalize the email address for git.

```
** Creating repo 'wiki' of type git to hold Wiki content at /opt/mtrack/var/repos/default/wiki
** (use --repo option to specify an alternate location)
** (use --wiki-type option to specify an alternate type)
PHP Notice: Undefined index: email in /opt/mtrack/inc/scm/git.php on line 194
wiki: Today
warning: You appear to have cloned an empty repository.
wiki: WikiStart
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '/opt/mtrack/var/repos/default/wiki'
```
affected #: 1 file

diff -r c335f24df2c7ad3a6cf66b37ab9ccf6ce5a7bb74 -r 4b22c77f1c44213c42da6cab9a96a49815106bf2 inc/scm/git.php
--- a/inc/scm/git.php
+++ b/inc/scm/git.php
@@ -95,7 +95,7 @@

function __destruct() {
if ($this->push) {
- echo stream_get_contents($this->git('push'));
+ echo stream_get_contents($this->git('push', 'origin', 'master'));
}
mtrack_rmdir($this->dir);
}
@@ -127,8 +127,7 @@
if (!strlen($reason)) {
$reason = 'Changed';
}
- putenv("GIT_AUTHOR_NAME=$CS->who");
- putenv("GIT_AUTHOR_EMAIL=$CS->who");
+ MTrackSCMGit::setGitEnvironment($CS->who);
stream_get_contents($this->git('commit', '-a',
'-m', $reason
)
@@ -184,16 +183,26 @@
return null;
}

+ /* I've had reports that Git becomes unhappy if it can't find something
+ * that looks like an email address, so try to normalize towards that */
+ static function setGitEnvironment($user) {
+ $userdata = MTrackAuth::getUserData($user);
+ if (preg_match("/@/", $userdata['email'])) {
+ $who = $userdata['email'];
+ } else {
+ $who = "$user@local";
+ }
+ putenv("GIT_AUTHOR_NAME=$who");
+ putenv("GIT_AUTHOR_EMAIL=$who");
+ }
+
public function reconcileRepoSettings(MTrackSCM $r = null) {
if ($r == null) {
$r = $this;
}

if (!is_dir($r->repopath)) {
- $userdata = MTrackAuth::getUserData(MTrackAuth::whoami());
- $who = $userdata['email'];
- putenv("GIT_AUTHOR_NAME=$who");
- putenv("GIT_AUTHOR_EMAIL=$who");
+ self::setGitEnvironment(MTrackAuth::whoami());

if ($r->clonedfrom) {
$S = MTrackRepo::loadById($r->clonedfrom);
@@ -206,21 +215,12 @@
}

} else {
- /* a little peculiar, but bear with it.
- * We need to have a bare repo so that git doesn't mess around
- * trying to deal with a checkout in the repo dir.
- * So we need to create two repos; one bare, one not bare.
- * We populate the non-bare repo with a dummy file just to have
- * something to commit, then push non-bare -> bare, and remove non-bare.
- */
-
$stm = mtrack_run_tool('git', 'read',
array('init', '--bare', $r->repopath));
$out = stream_get_contents($stm);
if (pclose($stm)) {
throw new Exception("git init failed: $out");
}
-
}

$php = MTrackConfig::get('tools', 'php');

Repository URL: https://bitbucket.org/wez/mtrack/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
Reply all
Reply to author
Forward
0 new messages