Verified Commit eae3d301 authored by Vasili Novikov's avatar Vasili Novikov
Browse files

Clean up, include git hash in http version

parent 488a6ccb
Showing with 11 additions and 19 deletions
+11 -19
......@@ -10,12 +10,14 @@ variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
APT_CACHE_DIR: $CI_PROJECT_DIR/apt
# WARNING:
# Project currently uses a dirty work-around:
# it installs dependencies/components on GitLab shell runner,
# as opposed to doing it in a reproducible fashion
#
# - apt-get update -yq
# - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y libsqlcipher-dev buildah
before_script:
# WARNING: dirty work-around:
# `libsqlcipher-dev` is right now installed on gitlab-runner (shell) host
- dpkg -l libsqlcipher-dev
# - apt-get update -yq
# - apt-get install -o dir::cache::archives="$APT_CACHE_DIR" -y libsqlcipher-dev
- rustup component add rustfmt
- rustup component add clippy
......
......@@ -14,7 +14,6 @@ use chrono::Utc;
use log::debug;
use log::info;
use r2d2::Pool;
use r2d2::PooledConnection;
use r2d2_sqlite::SqliteConnectionManager;
use rusqlite::ToSql;
use rusqlite::Transaction;
......@@ -26,20 +25,11 @@ use std::process::Command;
use std::str;
use warp::http::status::StatusCode;
/// Check if item exists by uid
pub fn _check_item_exist(
conn: &PooledConnection<SqliteConnectionManager>,
uid: i64,
) -> Result<bool> {
let sql = format!("SELECT COUNT(*) FROM items WHERE uid = {};", uid);
let result: i64 = conn.query_row(&sql, NO_PARAMS, |row| row.get(0))?;
Ok(result != 0)
}
/// Get project version as seen by Cargo.
pub fn get_project_version() -> &'static str {
debug!("Returning API version...");
env!("CARGO_PKG_VERSION")
pub fn get_project_version() -> String {
let git = env!("GIT_DESCRIBE");
let cargo = env!("CARGO_PKG_VERSION");
format!("{}-cargo{})", git, cargo)
}
/// See HTTP_API.md for details
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment