Permalink
Browse files

Merge branch 'merge-c27ffb7e-5b3d-40f7-a13c-e14ab2d5cbb6-YMOPQGVH7O5U…

…FCQFTXCBLXMTPGAQCELF'
  • Loading branch information...
yrashk committed Dec 20, 2018
2 parents 924f6a5 + 471159a commit eee5584024da9b4d3fec4064d094b7e03642727a
Showing with 92 additions and 129 deletions.
  1. +1 −0 .sit/items/c27ffb7e-5b3d-40f7-a13c-e14ab2d5cbb6/J66WNG37O4BXMU2223HQCBDIBG6LU5WP
  2. +1 −0 .sit/records/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/.authors
  3. 0 ...U/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/.prev/YMOPQGVH7O5UFCQFTXCBLXMTPGAQCELF
  4. +17 −0 .../records/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/.signature
  5. +1 −0 .../records/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/.timestamp
  6. 0 ...ecords/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/.type/Closed
  7. 0 ...ecords/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/.type/Merged
  8. +1 −0 .sit/records/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP/record
  9. +1 −1 README.md
  10. +1 −1 build-tools/cross-compile-osx/Dockerfile
  11. +1 −1 build-tools/linux-build-container/Dockerfile
  12. +1 −0 sit-core/Cargo.toml
  13. +3 −0 sit-core/src/encoding.rs
  14. +2 −1 sit-core/src/hash.rs
  15. +2 −0 sit-core/src/id.rs
  16. +0 −39 sit-core/src/lib.rs
  17. +3 −2 sit-core/src/record.rs
  18. +6 −3 sit-core/src/reducers/duktape.rs
  19. +7 −0 sit-core/src/repository.rs
  20. +3 −2 sit/Cargo.toml
  21. +8 −3 sit/src/authorship.rs
  22. +1 −0 sit/src/cfg.rs
  23. +3 −2 sit/src/cli.rs
  24. +8 −5 sit/src/command_record.rs
  25. +1 −1 sit/src/command_records.rs
  26. +9 −5 sit/src/command_web.rs
  27. +0 −6 sit/src/lib.rs
  28. +5 −56 sit/src/main.rs
  29. +1 −1 sit/tests/command_modules.rs
  30. +3 −0 sit/tests/command_record.rs
  31. +2 −0 sit/tests/command_web.rs
@@ -0,0 +1 @@
../../records/J6/6W/NG/37/O4/BX/MU/22/23/HQ/CB/DI/BG/6L/U5/J66WNG37O4BXMU2223HQCBDIBG6LU5WP
@@ -0,0 +1,17 @@
-----BEGIN PGP SIGNATURE-----

iQJCBAABCAAsFiEEjmkaFOaskcs7s6g8HWDXz9gIRf8FAlwb730OHG1lQHlyYXNo
ay5jb20ACgkQHWDXz9gIRf+XfxAAiC0XgJutQT5y9p2g0usvh8YEaqdLToMTkN+K
AwIjGIdCq+3a19KuNhl+xb46zZ6MsRDViEtKfNrAFcbLAfP6NK2RPUabTW8BhHI5
16qZyafbvViNzwaiF3U8PdOyAfec43fGV69z+NwrN5qGdk1uRuR3I4u7BAoT52j+
1d70SjYqONBKHtkZX7p5H2F8GOPuR66IK6L2j41+asvIZWs3cnbjghFHoYcFrNs5
X4vO1XnkCLqCxyrsdU/XUC85r76y89aqiwYmoofs1oBgUlCXJdeGkOmK5CvKn7Kb
N+DOzpGnCKM0zO+kvIDLV8Aj/Fo7LtGJjuYaT9D8SW9h/EMxJdX+4Cc2sQU7zY8A
QFPwmTzp2fT0snkqjQqHQDYyO49nm9piF5DOsxoL5tdPdwt37VIJclkeMgxIhHo6
/oeo/L0uUTtJRn0ikitW2nrXgE7YvP156C05Fks0PRbPlj6W3MuqOzYQCzrS7I4S
fbHVVAaTR33quP5vTw8u41yzVJaJZrLe+0Sdn2niVjWf+HfPZLw336WCZqHnvZiO
uFCoibkxSzXsNAwYDjsikoIImiOu4YJ/UtQx85Vkw44H7yb8FVzNTCoQ7nIp9A8v
zvEqUydC8f9K5RbsseWR6+HITwQP+EZ628sWhRQ03uu8dRYmunaj7GKoOTELaRrJ
hvFHQtI=
=3tgB
-----END PGP SIGNATURE-----
@@ -110,7 +110,7 @@ build SIT from sources.*
As SIT is currently in its early days, sometimes it might make sense to use a
pre-release build. We encourage that. It helps us building a better product.

Firstly, you will need to install Rust 1.30 and CMake. Luckily
Firstly, you will need to install Rust 1.31 and CMake. Luckily
it is typically a very simple process. You can find
instructions on [Rust's website](https://www.rust-lang.org/en-US/install.html).

@@ -1,4 +1,4 @@
FROM rust:1.30
FROM rust:1.31
RUN apt-get update && apt-get install -y clang autotools-dev automake cmake libfuse-dev fuse git
RUN rustup target add x86_64-apple-darwin
RUN git clone https://github.com/tpoechtrager/osxcross && cd osxcross && git checkout 1a1733a
@@ -1,4 +1,4 @@
FROM rust:1.30
FROM rust:1.31
RUN apt-get update && apt-get install -y cmake libgit2-dev musl-tools
RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get install -y clang libclang-dev
@@ -6,6 +6,7 @@ license = "MIT/Apache-2.0"
repository = "https://github.com/sit-it/sit"
documentation = "https://docs.rs/sit-core"
description = "Core library for SIT (Serverless Information Tracker)"
edition = "2018"

[dependencies]
derive-error = "0.0"
@@ -1,5 +1,8 @@
//! Binary identifier encodings

use serde_derive::{Deserialize, Serialize};
use data_encoding_macro::*;

/// Available encodings
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Encoding {
@@ -1,4 +1,5 @@
//! SIT uses hashing for content-addressable entities (such as records)
use serde_derive::{Deserialize, Serialize};

/// Enumerates known hashing algorithm. Its content depends on features
/// enabled during build-time
@@ -154,4 +155,4 @@ mod tests {
// 294863232e30c5580ee9410b7c35a2c6d3b6ceb3
assert_eq!(hasher.result_box(), vec![41, 72, 99, 35, 46, 48, 197, 88, 14, 233, 65, 11, 124, 53, 162, 198, 211, 182, 206, 179]);
}
}
}
@@ -1,5 +1,7 @@
//! ID generation abstraction

use serde_derive::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum IdGenerator {
/// UUID v4 (random)
@@ -7,45 +7,6 @@
//!
//! [`Repository`]: repository/struct.Repository.html

#[macro_use] extern crate derive_error;
#[macro_use] extern crate typed_builder;

// Serialization
extern crate serde;
#[macro_use] extern crate serde_derive;
pub extern crate serde_json;

extern crate tempdir;
extern crate glob;
extern crate data_encoding;
#[macro_use] extern crate data_encoding_macro;
#[macro_use] extern crate lazy_static;

// Hashing
extern crate digest;
#[cfg(feature = "blake2")] extern crate blake2;
#[cfg(feature = "sha-1")] extern crate sha1;

#[cfg(feature = "uuid")] extern crate uuid;

#[cfg(feature = "memmap")] extern crate memmap;

#[cfg(feature = "cesu8")] extern crate cesu8;

#[cfg(feature = "git")] extern crate git2;

#[cfg(test)] extern crate dunce;

extern crate relative_path;

extern crate itertools;
extern crate walkdir;

// Crates necessary for testing
#[cfg(test)] #[macro_use] extern crate assert_matches;
#[cfg(test)] #[macro_use] extern crate proptest;


pub mod path;
pub mod hash;
pub mod encoding;
@@ -3,6 +3,7 @@
use std::io::{self, Read};
use crate::hash::{Hasher, HashingAlgorithm};
use std::path::PathBuf;
use derive_error::Error;

/// Record's file
///
@@ -96,7 +97,7 @@ impl<'a, F: File> OrderedFiles<'a, F> {
for file in self.0.iter_mut() {
let name: String = file.name().into();
hasher.process(name.as_bytes());
let mut reader = file.read();
let reader = file.read();
let mut file_processor = per_file(&name)?;
loop {
let bytes_read = reader.read(&mut buf)?;
@@ -169,7 +170,7 @@ impl<'a, F, S> Sub<S> for OrderedFiles<'a, F> where F: File + 'a, S: AsRef<str>

#[cfg(test)]
mod ordered_files_tests {
use proptest::collection::*;
use proptest::{*, collection::*};
use super::*;

proptest! {
@@ -13,6 +13,8 @@ use std::io;
use crate::path::HasPath;
use crate::RepositoryError;

use derive_error::Error;

#[cfg(feature = "duktape-mmap")]
use memmap;

@@ -436,7 +438,7 @@ impl<R: Record + HasPath> Reducer for DuktapeReducer<R> {
duktape::duk_push_object(ctx);
#[cfg(feature = "duktape-mmap")]
let mut mmaps = vec![];
for (name, mut reader) in item.file_iter() {
for (name, reader) in item.file_iter() {
let filename = CString::new(name.as_ref()).unwrap();
#[cfg(feature = "duktape-mmap")] {
// avoid unused warning
@@ -503,7 +505,7 @@ impl<R: Record + HasPath> Reducer for DuktapeReducer<R> {
if res as u32 == duktape::DUK_EXEC_ERROR {
let err = std::ffi::CStr::from_ptr(duktape::duk_safe_to_lstring(ctx, -1, ptr::null_mut()));
{
let mut arr = state.entry(String::from("errors")).or_insert(JsonValue::Array(vec![]));
let arr = state.entry(String::from("errors")).or_insert(JsonValue::Array(vec![]));
let mut error = Map::new();
error.insert("file".into(), JsonValue::String(self.filenames[i as usize].to_str().unwrap().into()));
error.insert("error".into(), JsonValue::String(err.to_str().unwrap().into()));
@@ -523,7 +525,7 @@ impl<R: Record + HasPath> Reducer for DuktapeReducer<R> {
} else {
let err = format!("TypeError: invalid return value {}, expected an object", std::ffi::CStr::from_ptr(duktape::duk_safe_to_lstring(ctx, -1, ptr::null_mut())).to_string_lossy());
{
let mut arr = state.entry(String::from("errors")).or_insert(JsonValue::Array(vec![]));
let arr = state.entry(String::from("errors")).or_insert(JsonValue::Array(vec![]));
let mut error = Map::new();
error.insert("file".into(), JsonValue::String(self.filenames[i as usize].to_str().unwrap().into()));
error.insert("error".into(), JsonValue::String(err));
@@ -566,6 +568,7 @@ mod tests {
use crate::Repository;
use crate::record::{RecordOwningContainer, RecordContainerReduction};
use crate::path::HasPath;
use assert_matches::assert_matches;

#[test]
fn undefined_result() {
@@ -23,6 +23,10 @@ use super::id::IdGenerator;

use std::collections::HashMap;

use serde_derive::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
use derive_error::Error;

/// Current repository format version
const VERSION: &str = "1";
/// Current repository features
@@ -232,6 +236,8 @@ mod default_files {
use std::path::PathBuf;
use std::collections::HashMap;

use lazy_static::*;

lazy_static! {
pub static ref ASSETS: HashMap<PathBuf, File> = {
let mut map = HashMap::new();
@@ -1132,6 +1138,7 @@ mod tests {

use super::*;
use crate::path::HasPath;
use assert_matches::assert_matches;

#[test]
fn new_repo() {
@@ -4,6 +4,7 @@ version = "0.5.0-pre"
description = "Serverless Information Tracker"
authors = ["Yurii Rashkovskii <me@yrashk.com>"]
license = "MIT/Apache-2.0"
edition = "2018"

[dependencies]
clap = { version = "2.31", features = ["yaml"] }
@@ -12,6 +13,7 @@ chrono = "0.4"
tempfile = "2.2"
config = { version = "0.8", features = ["json"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
jmespath = { version = "0.2", features = ["sync"] }
fs_extra = "1.1"
@@ -34,7 +36,6 @@ digest = { version = "0.7", optional = true }
blake2 = { version = "0.7", optional = true }
hex = { version = "0.3", optional = true }
lazy_static = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
git2 = { version = "0.7", optional = true, default-features = false }
sit-core = { path = "../sit-core", version = "0.5.0-pre" }

@@ -51,5 +52,5 @@ fs_extra = "1.1"
default = ["deprecated-items", "web", "git"]
windows7 = ["sit-core/windows7"]
deprecated-items = ["sit-core/deprecated-item-api"]
web = ["rouille", "mime_guess", "digest", "blake2", "hex", "lazy_static", "serde_derive" ]
web = ["rouille", "mime_guess", "digest", "blake2", "hex", "lazy_static" ]
git = ["git2"]
@@ -1,12 +1,17 @@
use std::fs;
use std::path::Path;
use atty;
use crate::cfg::{self, Configuration};
use crate::cfg::Configuration;
use serde_json;

pub(crate) fn derive_authorship<P: AsRef<Path>, P1: AsRef<Path>>(config: &mut Configuration, working_dir: P, config_path: P1) -> i32 {
#[cfg(not(feature = "git"))]
let _ = working_dir; // to suppress the warning
if config.author.is_none() {
let authorship = cfg::Author::from_gitconfig(working_dir.as_ref().join(".git").join("config"));
#[cfg(feature = "git")]
let authorship = crate::cfg::Author::from_gitconfig(working_dir.as_ref().join(".git").join("config"));
#[cfg(not(feature = "git"))]
let authorship = None;
if authorship.is_some() {
config.author = authorship;
return 0;
@@ -38,7 +43,7 @@ pub(crate) fn derive_authorship<P: AsRef<Path>, P1: AsRef<Path>>(config: &mut Co
},
Some(answer) => panic!("Invalid answer {:?}", answer),
};
config.author = Some(cfg::Author { name, email });
config.author = Some(crate::cfg::Author { name, email });
let file =
fs::File::create(config_path).expect("can't open config file for writing");
serde_json::to_writer_pretty(file, &config).expect("can't write config");
@@ -1,6 +1,7 @@
//! Client configuration
#[cfg(feature = "git")]
use std::path::PathBuf;
use serde_derive::{Serialize, Deserialize};

#[derive(Clone, Serialize, Deserialize)]
pub struct Author {
@@ -2,7 +2,8 @@ use std::env;
use std::path::{Path, PathBuf};
use std::ffi::OsStr;
use sit_core::{self, Repository, path::HasPath};
use crate::which;
use which;
use derive_error::Error;

#[derive(Error, Debug)]
pub enum Error {
@@ -85,4 +86,4 @@ pub fn execute_cli<MI, E, K, V>(repo: &Repository<MI>, cwd: &Path, subcommand: &
let process = command.spawn()?;
let result = process.wait_with_output().unwrap();
Ok((result.status.code().unwrap(), result.stdout))
}
}
@@ -1,7 +1,7 @@
use chrono::prelude::*;
use clap::{self, ArgMatches};
use dunce;
use crate::cfg::{self, Configuration};
use crate::cfg::Configuration;
use crate::authorship::derive_authorship;
use sit_core::{
record::{BoxedOrderedFiles, OrderedFiles, RecordOwningContainer},
@@ -127,9 +127,12 @@ fn record_files(

pub fn command<P: AsRef<Path>, P1: AsRef<Path>, MI>(matches: &ArgMatches, repo: &Repository<MI>, mut config: Configuration, working_directory: P, config_path: P1) -> i32 {
if !matches.is_present("no-aux") && !matches.is_present("no-author") && config.author.is_none() {
if let Some(author) = cfg::Author::from_gitconfig(working_directory.as_ref().join(".git").join("config")) {
config.author = Some(author);
} else {
#[cfg(feature = "git")] {
if let Some(author) = crate::cfg::Author::from_gitconfig(working_directory.as_ref().join(".git").join("config")) {
config.author = Some(author);
}
}
if config.author.is_none() {
let result = derive_authorship(&mut config, working_directory, config_path.as_ref());
if result != 0 {
return result;
@@ -208,7 +211,7 @@ pub fn command<P: AsRef<Path>, P1: AsRef<Path>, MI>(matches: &ArgMatches, repo:
let mut child = command.spawn().expect("failed spawning gnupg");

{
let mut stdin = child.stdin.as_mut().expect("Failed to open stdin");
let stdin = child.stdin.as_mut().expect("Failed to open stdin");
let mut hasher = repo.config().hashing_algorithm().hasher();
files.hash(&mut *hasher).expect("failed hashing files");
let hash = hasher.result_box();
@@ -77,7 +77,7 @@ fn list<R: RecordContainer, MI>(matches: &ArgMatches, iter: &R, repo: &Repositor
let hash = hasher.result_box();
let encoded_hash = repo.config().encoding().encode(&hash);
use std::io::Write;
let mut stdin = child.stdin.as_mut().expect("Failed to open stdin");
let stdin = child.stdin.as_mut().expect("Failed to open stdin");
stdin.write_all(encoded_hash.as_bytes()).expect("Failed to write to stdin");
}

Oops, something went wrong.

0 comments on commit eee5584

Please sign in to comment.