From 5b28fd8a792a6e5e3dbb22ab0aa3b31bac69daf3 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 29 Mar 2022 12:42:15 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=20c76b3?= =?UTF-8?q?5119876c174c02650dafa3496e43150f6a0=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/constant.GIT_COMMIT_HASH.html | 2 +- pages/page/index.html | 2 +- pages/page/struct.Page.html | 2 +- src/pages/page.rs.html | 220 +++++++++++++++++----------- 4 files changed, 140 insertions(+), 86 deletions(-) diff --git a/pages/constant.GIT_COMMIT_HASH.html b/pages/constant.GIT_COMMIT_HASH.html index 41757d0..2322394 100644 --- a/pages/constant.GIT_COMMIT_HASH.html +++ b/pages/constant.GIT_COMMIT_HASH.html @@ -1,4 +1,4 @@ GIT_COMMIT_HASH in pages - Rust

Constant pages::GIT_COMMIT_HASH[][src]

pub const GIT_COMMIT_HASH: &str = "3c40a32fba67ec55744c7b40183e83d6adbce9b6";
+

Constant pages::GIT_COMMIT_HASH[][src]

pub const GIT_COMMIT_HASH: &str = "c76b35119876c174c02650dafa3496e43150f6a0";
\ No newline at end of file diff --git a/pages/page/index.html b/pages/page/index.html index 290e634..5b143b4 100644 --- a/pages/page/index.html +++ b/pages/page/index.html @@ -1,5 +1,5 @@ pages::page - Rust

Module pages::page[][src]

Structs

+

Module page

Module pages::page[][src]

Structs

\ No newline at end of file diff --git a/pages/page/struct.Page.html b/pages/page/struct.Page.html index 0cdab08..28bf9cd 100644 --- a/pages/page/struct.Page.html +++ b/pages/page/struct.Page.html @@ -5,7 +5,7 @@ pub repo: String, pub path: String, pub branch: String, -}

Fields

secret: Stringrepo: Stringpath: Stringbranch: String

Implementations

Trait Implementations

Returns a copy of the value. Read more

+}

Fields

secret: Stringrepo: Stringpath: Stringbranch: String

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

diff --git a/src/pages/page.rs.html b/src/pages/page.rs.html index 03c3fa1..0300c00 100644 --- a/src/pages/page.rs.html +++ b/src/pages/page.rs.html @@ -1,82 +1,109 @@ page.rs - source
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
+        
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
 
/*
  * Copyright (C) 2022  Aravinth Manivannan <realaravinth@batsense.net>
  *
@@ -106,7 +133,7 @@
 }
 
 impl Page {
-    pub fn create_repo(&self) -> Repository {
+    fn create_repo(&self) -> Repository {
         let repo = Repository::open(&self.path);
 
         if let Ok(repo) = repo {
@@ -115,9 +142,7 @@
             info!("Cloning repository {} at {}", self.repo, self.path);
             Repository::clone(&self.repo, &self.path).unwrap()
         };
-        //        let branch = repo.find_branch(&self.branch, BranchType::Local).unwrap();
 
-        //repo.branches(BranchType::Local).unwrap().find(|b| b.unwrap().na
         let repo = Repository::open(&self.path).unwrap();
         {
             self._fetch_upstream(&repo, &self.branch);
@@ -132,11 +157,8 @@
 
             repo.checkout_tree(&tree, Some(&mut checkout_options))
                 .unwrap();
-            //                repo.set_head(&format!("refs/heads/{}", &self.branch))
-            //                    .unwrap();
 
             repo.set_head(branch.get().name().unwrap()).unwrap();
-            //           }
         }
         repo
     }
@@ -154,6 +176,38 @@
         self._fetch_upstream(&repo, branch);
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    use mktemp::Temp;
+
+    #[actix_rt::test]
+    async fn pages_works() {
+        let tmp_dir = Temp::new_dir().unwrap();
+        assert!(tmp_dir.exists(), "tmp directory successully created");
+        let page = Page {
+            secret: String::default(),
+            repo: "https://github.com/mcaptcha/website".to_owned(),
+            path: tmp_dir.to_str().unwrap().to_string(),
+            branch: "gh-pages".to_string(),
+        };
+
+        assert!(
+            Repository::open(tmp_dir.as_path()).is_err(),
+            "repository doesn't exist yet"
+        );
+
+        let repo = page.create_repo();
+        assert!(!repo.is_bare(), "repository isn't bare");
+        page.create_repo();
+        assert!(
+            Repository::open(tmp_dir.as_path()).is_ok(),
+            "repository exists yet"
+        );
+    }
+}
 
\ No newline at end of file