mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
refactor(output): share the JSON, created-resource and batch tails
Mutations end with a.jsonResult or a.created instead of hand-rolled --json branches, the two identical jsonResult/writeMutationJSON helpers become one, and writeBatchJSON checks --json itself so batch commands share one tail. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
32 files changed
+87
-217
No files matched your search
@@ -91,11 +91,8 @@ $ tea repo sync bob/project`,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if a.options.json != "" {
|
||||
return a.writeJSON(cmd, result)
|
||||
}
|
||||
a.reportSync(cmd, result, remote+"/"+result.Branch)
|
||||
return nil
|
||||
return a.jsonResult(cmd, result)
|
||||
},
|
||||
}
|
||||
command.Flags().StringVarP(&branch, "branch", "b", "", "Branch to sync (default: the repository's default branch)")
|
||||
@@ -118,7 +115,7 @@ func (a *application) syncOnServer(cmd *cobra.Command, t target, branch string)
|
||||
return err
|
||||
}
|
||||
a.done(cmd, "Started updating the mirror %s from its source", item.FullName)
|
||||
return a.writeMutationJSON(cmd, git.SyncResult{Remote: mirrorSourceURL(item)})
|
||||
return a.jsonResult(cmd, git.SyncResult{Remote: mirrorSourceURL(item)})
|
||||
case !item.Fork || item.Parent == nil:
|
||||
return clierr.Wrap(clierr.Usage, fmt.Errorf("%s is neither a fork nor a mirror, and has no Git remote here; run tea repo sync inside a clone of it", item.FullName))
|
||||
}
|
||||
@@ -141,7 +138,7 @@ func (a *application) syncOnServer(cmd *cobra.Command, t target, branch string)
|
||||
} else {
|
||||
a.done(cmd, "Synced %s %s from %s (fast-forward %s..%s)", item.FullName, branch, item.Parent.FullName, shortSHA(result.Previous), shortSHA(result.Commit))
|
||||
}
|
||||
return a.writeMutationJSON(cmd, result)
|
||||
return a.jsonResult(cmd, result)
|
||||
}
|
||||
|
||||
// reportSync tells how a sync from source, such as origin/main, changed the branch.
|
||||
|
||||
Reference in new issue
Block a user