Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include git hash and crate version #977

Merged
merged 8 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/forest_libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ipld_blockstore = "0.1"
async-trait = "0.1"
lazy_static = "1.4"
futures_cbor_codec = { git = "https://github.com/najamelan/futures_cbor_codec", rev = "de08e31530513f993cbf5efef7311ac5194b2256" }
git-version = "0.3.4"

[dev-dependencies]
forest_address = "0.3"
Expand Down
10 changes: 7 additions & 3 deletions node/forest_libp2p/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
use forest_cid::Cid;
use futures::channel::oneshot::{self, Sender as OneShotSender};
use futures::{prelude::*, stream::FuturesUnordered};
use git_version::git_version;
use libp2p::core::PeerId;
use libp2p::gossipsub::{
error::PublishError, Gossipsub, GossipsubConfig, GossipsubEvent, MessageAuthenticity, Topic,
Expand Down Expand Up @@ -45,6 +46,11 @@ use std::{collections::HashMap, convert::TryInto};
use std::{task::Context, task::Poll};
use tiny_cid::Cid as Cid2;

lazy_static! {
static ref VERSION: &'static str = env!("CARGO_PKG_VERSION");
static ref CURRENT_COMMIT: &'static str = git_version!();
}

#[derive(NetworkBehaviour)]
#[behaviour(out_event = "ForestBehaviourEvent", poll_method = "poll")]
pub struct ForestBehaviour {
Expand Down Expand Up @@ -434,9 +440,7 @@ impl ForestBehaviour {
ping: Ping::default(),
identify: Identify::new(
"ipfs/0.1.0".into(),
// TODO update to include actual version
// https://github.com/ChainSafe/forest/issues/934
format!("forest-{}", "0.1.0"),
format!("forest-{}-{}", *VERSION, *CURRENT_COMMIT),
local_key.public(),
),
bitswap,
Expand Down
2 changes: 1 addition & 1 deletion types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ base64 = { version = "0.13", optional = true }
forest_json_utils = { path = "../utils/json_utils", optional = true, version = "0.1" }
lazy_static = "1.4"
async-std = "1.9"

git-version = "0.3.4"

[features]
json = ["base64", "forest_json_utils", "num-bigint/json"]
Expand Down
27 changes: 3 additions & 24 deletions types/src/build_version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use async_std::sync::RwLock;
use git_version::git_version;
use num_derive::FromPrimitive;
use std::{
fmt::{Display, Formatter, Result as FmtResult},
process::Command,
};
use std::fmt::{Display, Formatter, Result as FmtResult};

use serde::Serialize;
const BUILD_VERSION: &str = "0.10.2";
Expand All @@ -23,26 +21,7 @@ const MINER_API_VERSION: Version = new_version(0, 15, 0);
const WORKER_API_VERSION: Version = new_version(0, 15, 0);

lazy_static! {
static ref CURRENT_COMMIT: String = {
let output = Command::new("git")
.args(&[
"describe",
"--always",
"--match=NeVeRmAtch",
"--dirty",
"2>/dev/null",
])
.output()
.map(|s| s.stdout)
.unwrap_or_else(|_| {
Command::new("git")
.args(&["rev-parse", "--short", "HEAD", "2>/dev/null"])
.output()
.map(|s| s.stdout)
.unwrap_or_default()
});
String::from(std::str::from_utf8(&output).unwrap_or_default())
};
pub static ref CURRENT_COMMIT: String = git_version!().to_string();
pub static ref BUILD_TYPE: RwLock<BuildType> = RwLock::new(BuildType::BuildDefault);
pub static ref RUNNING_NODE_TYPE: RwLock<NodeType> = RwLock::new(NodeType::Full);
}
Expand Down