$list = Branch::enlist($gitWorkingCopyDir, isset($opts->remote), isset($opts->merged)); $charInput = new SttyCharInput(); $confirmed = true; foreach (new PregMatchIterator('~^(.*)/task-([0-9]+)(-.+)?$~', $list) as $matches) { $issueId = $matches[2]; if (isset($opts->before) && $issueId >= $opts->before) { continue; } $branchFullName = $matches[0]; echo $issueId . ': ' . $branchFullName . ' '; $branch = new Branch($gitWorkingCopyDir, $branchFullName); $issue = new Issue(); $issue->find($issueId); if ($issue->count()) { echo '[' . $issue->status['name'] . '] '; if (in_array($issue->status['id'], Naf::config('redmine.closed_issue_status_ids'))) { if (!$opts->force) { echo 'Delete ' . ($branch->isRemote() ? 'remote' : 'local') . ' branch? (y/N) '; $confirmed = $charInput->confirm(); } if ($confirmed) { try { $branch->delete(); echo ' Deleted'; } catch (ShellCmd\Fault $e) { echo $e->getMessage(); } } } } else { echo 'Issue not found';
if ($ts) { $date = date('Y-m-d', $ts); } else { echo "Cannot recognize date format\n\n"; exit(2); } $redmineTagId = Db::assertTagId(Naf::config('hamster.tag_text')); foreach (Db::selectFactsByDate($date)->fetchAll() as $fact) { echo $fact['name'] . ' ..'; $matches = null; if (!preg_match('~#([0-9]+)~', $fact['name'], $matches)) { echo " skipping\n"; continue; } $issue_id = $matches[1]; if (Db::isFactTaggedBy($fact['id'], $redmineTagId)) { echo " allready logged\n"; continue; } $hours = round($fact['hours'], 1); $entry = new TimeEntry(array('issue_id' => $issue_id, 'spent_on' => $date, 'hours' => (string) $hours, 'comments' => '', 'activity_id' => (string) Naf::config('redmine.activity.development'))); $entry->save(); if (!$entry->id) { //id property is served by __get() method echo " error\n"; continue; } echo ' ' . $hours . 'H'; Db::tagFactBy($fact['id'], $redmineTagId); echo " ok\n"; }