GithubHelp home page GithubHelp logo

sonro / radicle-surf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from radicle-dev/radicle-surf

0.0 0.0 0.0 277 KB

A code browsing library for VCS file systems

Rust 98.71% Dockerfile 1.21% Nix 0.09%

radicle-surf's Introduction

radicle-surf

A code surfing library for VCS file systems ๐Ÿ„โ€โ™€๏ธ๐Ÿ„โ€โ™‚๏ธ

Welcome to radicle-surf!

radicle-surf is a system to describe a file-system in a VCS world. We have the concept of files and directories, but these objects can change over time while people iterate on them. Thus, it is a file-system within history and we, the user, are viewing the file-system at a particular snapshot. Alongside this, we will wish to take two snapshots and view their differences.

Let's start surfing (and apologies for the unwraps):

use radicle_surf::vcs::git;
use radicle_surf::file_system::{Label, Path, SystemType};

// We're going to point to this repo.
let repo = git::Repository::new(".").unwrap();

// Here we initialise a new Browser for the git repo.
let browser = git::Browser::new(&repo).unwrap();

// Get the snapshot of the directory for our current
// HEAD of history.
let directory = browser.get_directory().unwrap();

// Let's get a Path to this file
let this_file = Path::with_root(&["src".into(), "lib.rs".into()]);

// And assert that we can find it!
assert!(directory.find_file(&this_file).is_some());

let mut root_contents = directory.list_directory();
root_contents.sort();

assert_eq!(root_contents, vec![
  SystemType::directory(".buildkite".into()),
  SystemType::directory(".docker".into()),
  SystemType::directory(".git".into()),
  SystemType::file(".gitignore".into()),
  SystemType::file("Cargo.toml".into()),
  SystemType::file("README.md".into()),
  SystemType::directory("data".into()),
  SystemType::directory("docs".into()),
  SystemType::directory("src".into()),
]);

let src = directory.find_directory(&Path::with_root(&["src".into()])).unwrap();
let mut src_contents = src.list_directory();
src_contents.sort();

assert_eq!(src_contents, vec![
  SystemType::directory("diff".into()),
  SystemType::directory("file_system".into()),
  SystemType::file("lib.rs".into()),
  SystemType::directory("vcs".into()),
]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.