Add firmware commit to bot state

pull/403/head
connor rigby 2018-01-05 10:16:36 -08:00 committed by Connor Rigby
parent e3f8f39355
commit 6bc05f5151
3 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,7 @@ defmodule Farmbot.BotState do
use GenStage
@version Farmbot.Project.version()
@commit Farmbot.Project.commit()
@arduino_commit Farmbot.Project.arduino_commit()
@target Farmbot.Project.target()
@env Farmbot.Project.env()
@ -282,6 +283,7 @@ defmodule Farmbot.BotState do
informational_settings: %{
controller_version: @version,
firmware_version: "disconnected",
firmware_commit: @arduino_commit,
commit: @commit,
target: @target,
env: @env,

View File

@ -4,6 +4,7 @@ defmodule Farmbot.Project do
@version Mix.Project.config[:version]
@target Mix.Project.config[:target]
@commit Mix.Project.config[:commit]
@arduino_commit Mix.Project.config[:arduino_commit]
@env Mix.env()
@doc "*#{@version}*"
@ -14,6 +15,10 @@ defmodule Farmbot.Project do
@compile {:inline, commit: 0}
def commit, do: @commit
@doc "*#{@arduino_commit}*"
@compile {:inline, arduino_commit: 0}
def arduino_commit, do: @arduino_commit
@doc "*#{@target}*"
@compile {:inline, target: 0}
def target, do: @target

View File

@ -3,10 +3,15 @@ defmodule Farmbot.Mixfile do
@target System.get_env("MIX_TARGET") || "host"
@version Path.join(__DIR__, "VERSION") |> File.read!() |> String.trim()
defp commit() do
defp commit do
System.cmd("git", ~w"rev-parse --verify HEAD") |> elem(0) |> String.trim()
end
defp arduino_commit do
opts = [cd: "c_src/farmbot-arduino-firmware"]
System.cmd("git", ~w"rev-parse --verify HEAD", opts) |> elem(0) |> String.trim()
end
Mix.shell().info([
:green,
"""
@ -28,6 +33,7 @@ defmodule Farmbot.Mixfile do
version: @version,
target: @target,
commit: commit(),
arduino_commit: arduino_commit(),
archives: [nerves_bootstrap: "~> 0.6.0"],
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,