defmodule Mix.Tasks.Gitgud.BackfillDesktopIcons do
@moduledoc """
Re-read published `.deb`s and `.rpm`s so the packages pages can show
the name and icon from their desktop entry.
Both are read out of the package at upload, so anything published
before the adapters looked for a desktop entry carries neither — and
nothing re-reads a package afterwards.
mix gitgud.backfill_desktop_icons # newest file per package
mix gitgud.backfill_desktop_icons --all # every version
mix gitgud.backfill_desktop_icons --dry-run # say what would change
Starts the Repo alone rather than the whole application, so it can be
run against a live instance.
The walk itself is `GitGud.Packages.Formats.Desktop.backfill_icons/1`,
shared with `GitGud.Release.backfill_desktop_icons/1` for a deployed
instance, which has no Mix.
"""
@shortdoc "Fill in .deb/.rpm names and icons from their desktop entries"
use Mix.Task
alias GitGud.Packages.Formats.Desktop
@impl true
def run(args) do
{opts, _rest, _invalid} =
OptionParser.parse(args, strict: [all: :boolean, dry_run: :boolean])
Mix.Task.run("app.config")
{:ok, _} = Application.ensure_all_started(:ecto_sql)
{:ok, _} = Application.ensure_all_started(:postgrex)
started? =
case GitGud.Repo.start_link() do
{:ok, _pid} -> true
{:error, {:already_started, _pid}} -> false
end
{read, written} =
Desktop.backfill_icons(
Keyword.put(opts, :on_file, &Mix.shell().info(Desktop.describe_backfill(&1)))
)
Mix.shell().info("\n#{read} package file(s) read, #{written} updated.")
if started?, do: GitGud.Repo.stop()
end
end
neiam
/gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
1
Log in to mark this repository.
1.7 KiB · text
History
69f26e0