List of commits:
Subject Hash Author Date (UTC)
Implement non-recursive dependency check. 5ffd40604755d1c2dde9353c74f06a006deea33c Jan Allersma 2018-12-07 20:50:42
Restructure project. c2d98caf7897e87284fb2891e1d4b92d14cf37e1 Jan Allersma 2018-12-06 16:20:46
Initial commit. 4c152d55edc20ac55fd749a2b32b204134a664e3 Jan Allersma 2018-12-05 17:03:08
Commit 5ffd40604755d1c2dde9353c74f06a006deea33c - Implement non-recursive dependency check.
Author: Jan Allersma
Author date (UTC): 2018-12-07 20:50
Committer name: Jan Allersma
Committer date (UTC): 2018-12-07 20:50
Parent(s): c2d98caf7897e87284fb2891e1d4b92d14cf37e1
Signing key:
Tree: 5bcfe0dbe3dd918c46d6625bd59bb5048ba4295e
File Lines added Lines deleted
src/backend/check.rs 46 10
src/backend/fetch.rs 5 2
src/backend/filesystem.rs 19 1
File src/backend/check.rs changed (mode: 100644) (index 6885a45..08d2bca)
1 1 extern crate serde_json; extern crate serde_json;
2 2
3 use std::io::{Result, Error, ErrorKind, Write};
3 use std::io::{Result, Error, ErrorKind};
4 4
5 5 pub fn dep(config: String) -> Result<String> { pub fn dep(config: String) -> Result<String> {
6 6 let config_json: serde_json::Value; let config_json: serde_json::Value;
 
... ... pub fn dep(config: String) -> Result<String> {
37 37 } }
38 38 } }
39 39
40 pkg_check(config_json)
40 config_check(config_json)
41 41 } }
42 42
43 43 #[cfg(target_os="linux")] #[cfg(target_os="linux")]
44 fn pkg_check(config: serde_json::Value) -> Result<String> {
44 fn config_check(config: serde_json::Value) -> Result<String> {
45 45 match config["deps"]["linux"] { match config["deps"]["linux"] {
46 46 json!(null) => return Ok(String::from("No dependencies found!")), json!(null) => return Ok(String::from("No dependencies found!")),
47 47 ref deps => { ref deps => {
48 48 if !deps.is_object() { if !deps.is_object() {
49 49 return Err(Error::new(ErrorKind::InvalidData, "beheer.json: 'deps->linux' should be an object.")); return Err(Error::new(ErrorKind::InvalidData, "beheer.json: 'deps->linux' should be an object."));
50 50 } }
51
51 52 for dep in deps.as_object().unwrap().iter() { for dep in deps.as_object().unwrap().iter() {
53
52 54 if !dep.1.is_string() { if !dep.1.is_string() {
53 55 return Err(Error::new(ErrorKind::InvalidData, "beheer.json: all deps should be strings!")); return Err(Error::new(ErrorKind::InvalidData, "beheer.json: all deps should be strings!"));
54 56 } }
57
55 58 println!("Checking for {}..\n\t{}", dep.0, dep.1); println!("Checking for {}..\n\t{}", dep.0, dep.1);
56 super::fetch::fetch(dep.0.to_string(), String::from(dep.1.as_str().unwrap()));
59
60 match dir_check(dep.0.to_string(), String::from(dep.1.as_str().unwrap())) {
61 Ok(_) => {},
62 Err(e) => return Err(e)
63 }
57 64 } }
58 65 } }
59 66 } }
 
... ... fn pkg_check(config: serde_json::Value) -> Result<String> {
61 68 } }
62 69
63 70 #[cfg(target_os="macos")] #[cfg(target_os="macos")]
64 fn pkg_check(config: serde_json::Value) -> Result<String> {
71 fn config_check(config: serde_json::Value) -> Result<String> {
65 72 match config["deps"]["os-x"] { match config["deps"]["os-x"] {
66 73 json!(null) => return Ok(String::from("No dependencies found!")), json!(null) => return Ok(String::from("No dependencies found!")),
67 74 ref sys_deps => { ref sys_deps => {
68 75 if !sys_deps.is_object() { if !sys_deps.is_object() {
69 76 return Err(Error::new(ErrorKind::InvalidData, "beheer.json: 'deps->os-x' should be an object.")); return Err(Error::new(ErrorKind::InvalidData, "beheer.json: 'deps->os-x' should be an object."));
70 77 } }
71 for dep in sys_deps.as_object().unwrap().iter() {
78
79 for dep in deps.as_object().unwrap().iter() {
80
72 81 if !dep.1.is_string() { if !dep.1.is_string() {
73 82 return Err(Error::new(ErrorKind::InvalidData, "beheer.json: all deps should be strings!")); return Err(Error::new(ErrorKind::InvalidData, "beheer.json: all deps should be strings!"));
74 83 } }
75 println!("Checking for {} version {}..", dep.0, dep.1);
84
85 println!("Checking for {}..\n\t{}", dep.0, dep.1);
86
87 if dir_check(dep.0.to_string(), String::from(dep.1.as_str().unwrap())) == Err(e) {
88 return Err(e);
89 }
76 90 } }
77 91 } }
78 92 } }
 
... ... fn pkg_check(config: serde_json::Value) -> Result<String> {
80 94 } }
81 95
82 96 #[cfg(target_os="windows")] #[cfg(target_os="windows")]
83 fn pkg_check(config: serde_json::Value) -> Result<String> {
97 fn config_check(config: serde_json::Value) -> Result<String> {
84 98 match config["deps"]["windows"] { match config["deps"]["windows"] {
85 99 json!(null) => return Ok(String::from("No dependencies found!")), json!(null) => return Ok(String::from("No dependencies found!")),
86 100 ref sys_deps => { ref sys_deps => {
87 101 if !sys_deps.is_object() { if !sys_deps.is_object() {
88 102 return Err(Error::new(ErrorKind::InvalidData, "beheer.json: 'deps->windows' should be an object.")); return Err(Error::new(ErrorKind::InvalidData, "beheer.json: 'deps->windows' should be an object."));
89 103 } }
90 for dep in sys_deps.as_object().unwrap().iter() {
104
105 for dep in deps.as_object().unwrap().iter() {
91 106 if !dep.1.is_string() { if !dep.1.is_string() {
92 107 return Err(Error::new(ErrorKind::InvalidData, "beheer.json: all deps should be strings!")); return Err(Error::new(ErrorKind::InvalidData, "beheer.json: all deps should be strings!"));
93 108 } }
94 println!("Checking for {} version {}..", dep.0, dep.1);
109
110 println!("Checking for {}..\n\t{}", dep.0, dep.1);
111
112 if dir_check(dep.0.to_string(), String::from(dep.1.as_str().unwrap())) == Err(e) {
113 return Err(e);
114 }
95 115 } }
96 116 } }
97 117 } }
98 118 Ok(String::from("Dependencies OK!")) Ok(String::from("Dependencies OK!"))
99 119 } }
120
121 fn dir_check(dependency: String, command: String) -> Result<()> {
122 let dir = super::filesystem::get_dep_dir();
123
124 match dir {
125 Ok(mut dep_dir) => {
126 dep_dir.push(dependency);
127 if !dep_dir.is_dir() {
128 dep_dir.pop();
129 super::fetch::fetch(dep_dir, command);
130 }
131 Ok(())
132 },
133 Err(e) => Err(e)
134 }
135 }
File src/backend/fetch.rs changed (mode: 100644) (index 6160248..613e432)
1 1 use std::process::Command; use std::process::Command;
2 use std::path;
2 3
3 pub fn fetch(dep: String, command: String) {
4 let out = Command::new(command).output().expect("");
4 pub fn fetch(dep: path::PathBuf, command: String) {
5 let mut args: Vec<&str> = command.split(' ').collect();
6 let command = args.remove(0);
7 let out = Command::new(command).current_dir(dep).args(args).output().expect("");
5 8
6 9 println!("{:#?}", out.stderr); println!("{:#?}", out.stderr);
7 10 } }
File src/backend/filesystem.rs changed (mode: 100644) (index e61a3c6..71578e5)
1 use std::{path, env};
1 use std::{path, env, fs};
2 use std::io::{Result, Error, ErrorKind};
2 3
3 4 fn get_root (mut path: path::PathBuf) -> Option<path::PathBuf> { fn get_root (mut path: path::PathBuf) -> Option<path::PathBuf> {
4 5 loop { loop {
 
... ... pub fn get_project_root() -> Option<path::PathBuf> {
36 37 } }
37 38 } }
38 39 } }
40
41 pub fn get_dep_dir() -> Result<path::PathBuf> {
42 match get_project_root() {
43 Some(mut path) => {
44 path.push("dep");
45 if !path.is_dir() {
46 println!("No dep folder found. Creating folder..");
47 match fs::create_dir(path.clone()) {
48 Ok(_) => println!("Created dir {}.", path.clone().to_str().unwrap()),
49 Err(e) => return Err(e)
50 }
51 }
52 Ok(path)
53 },
54 None => Err(Error::new(ErrorKind::NotFound, "No project file found. Aborted."))
55 }
56 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-Beheer

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-Beheer

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-Beheer

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main