This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  5179a9df23abfdbd5d421ce86ac00781777e795b (commit)
      from  e894d0b8d3386542a9082b6c775089092c0037c4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=5179a9df23abfdbd5d421ce86ac00781777e795b

commit 5179a9df23abfdbd5d421ce86ac00781777e795b
Author: Franck Villaume <[email protected]>
Date:   Sun Apr 30 13:52:56 2017 +0200

    forge cli: initial code for artifactImport

diff --git a/src/bin/forge b/src/bin/forge
index 5f77679..6ba8218 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -173,6 +173,8 @@ class CliActions {
                $artifactDump['id'] = $aid;
                $artf = artifact_get_object($aid);
                if ($artf && is_object($artf) && !$artf->isError()) {
+                       $artifactDump = (array)$artf;
+                       unset($artifactDump['ArtifactType']);
                        $artifactDump['history'] = array();
                        $hist = $artf->getHistory();
                        if (db_numrows($hist) > 0) {
@@ -180,8 +182,6 @@ class CliActions {
                                        $artifactDump['history'][] = $arr;
                                }
                        }
-                       $artifactDump['artifact'] = (array)$artf;
-                       unset($artifactDump['artifact']['ArtifactType']);
                        $artifactDump['monitor'] = $artf->getMonitorIds();
                        $artifactDump['messages'] = array();
                        $messages = $artf->getMessages();
@@ -193,18 +193,18 @@ class CliActions {
                        $files = $artf->getFiles();
                        foreach ($files as $key => $file) {
                                unset($file->Artifact);
-                               $artifactDump['artifact']['files'][$key] = 
(array)$file;
-                               
$artifactDump['artifact']['files'][$key]['storageref'] = $file->getFile();
+                               $artifactDump['files'][$key] = (array)$file;
+                               $artifactDump['files'][$key]['storageref'] = 
$file->getFile();
                        }
-                       $artifactDump['artifact']['relatedtasks'] = array();
+                       $artifactDump['relatedtasks'] = array();
                        $tasks = $artf->getRelatedTasks();
                        if (db_numrows($tasks) > 0) {
                                while ($arr = db_fetch_array($tasks, 
PGSQL_ASSOC)) {
-                                       
$artifactDump['artifact']['relatedtasks'][] = $arr;
+                                       $artifactDump['relatedtasks'][] = $arr;
                                }
                        }
-                       $artifactDump['artifact']['votes'] = $artf->getVotes();
-                       $artifactDump['artifact']['extra_field_data'] = 
$artf->getExtraFieldDataText();
+                       $artifactDump['votes'] = $artf->getVotes();
+                       $artifactDump['extra_field_data'] = 
$artf->getExtraFieldDataText();
                } else {
                        $artifactDump['error'][] = _('Unable to get artifact 
id')._(': ').$aid;
                }
@@ -213,6 +213,41 @@ class CliActions {
                return $artifactDump;
        }
 
+       function artifactImport($file, $format = 'json') {
+               global $importRefMapping;
+               $stream = $this->loadFile($file, $format);
+               if (!$stream) {
+                       return false;
+               }
+               $group_artifact_id = 
$this->getMappingId($stream['data_array']['group_artifact_id'], 'tracker');
+               $at = artifactType_get_object($group_artifact_id);
+               if ($at && is_object($at) && !$at->isError()) {
+                       db_begin();
+                       $artf = new Artifact($at);
+                       $summary = $stream['data_array']['summary'];
+                       $details = $stream['data_array']['details'];
+                       $assigned_to = 
$this->getMappingId($stream['data_array']['assigned_to'], 'user');
+                       $priority = $stream['data_array']['priority'];
+                       $extra_fields = array();
+                       $importData['user'] = 
$this->getMappingId($stream['data_array']['submitted_by'], 'user');
+                       $importData['nopermcheck'] = true;
+                       $importData['nonotice'] = true;
+                       $importData['time'] = 
$stream['data_array']['open_date'];
+                       if (!$artf->create($summary, $details, $assigned_to, 
$priority, $extra_fields, $importData)) {
+                               echo $artf->getErrorMessage()."\n";
+                               db_rollback();
+                               return false;
+                       }
+                       db_commit();
+                       
$importRefMapping['artifact'][$stream['data_array']['artifact_id']] = null;
+                       echo _('Artifact injected')."\n";
+                       return true;
+               } else {
+                       echo _('Unable to get tracker to inject artifact')._(': 
').$group_artifact_id."\n";
+                       return false;
+               }
+       }
+
        function groupDump($lgroup_id, $format = 'json') {
                // that is ugly... group_id is used as global var. it needs to 
be defined.
                global $group_id;
@@ -385,8 +420,7 @@ class CliActions {
                                        db_rollback();
                                        return false;
                                }
-                               $created_by = 
$this->getMappingId($version['created_by'], 'user');
-                               $importData['user'] = $created_by;
+                               $importData['user'] = 
$this->getMappingId($version['created_by'], 'user');
                                $importData['nopermcheck'] = true;
                                $importData['nonotice'] = true;
                                $importData['time'] = $version['createdate'];
@@ -422,8 +456,7 @@ class CliActions {
                                                        $reviewoptionalusers[] 
= $userid;
                                                }
                                        }
-                                       $created_by = 
$this->getMappingId($review['created_by'], 'user');
-                                       $importData['user'] = $created_by;
+                                       $importData['user'] = 
$this->getMappingId($review['created_by'], 'user');
                                        $importData['startdate'] = 
$review['startdate'];
                                        $importData['enddate'] = 
$review['enddate'];
                                        $importData['nonotice'] = true;

-----------------------------------------------------------------------

Summary of changes:
 src/bin/forge | 57 +++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to