Comments (4)
Scratch that, let me try and implement this again and see what happens.
from gitoxide.
Hi @Byron,
I've updated GitSync to (which Comtrya uses) to use this for clone_repository()
fn clone_repository(&self) -> Result<(), errors::GitSyncError> {
info!("Attempting to clone {} to {:?}", self.repo, self.dir,);
unsafe {
match gix::interrupt::init_handler(1, || {}) {
Ok(_) => (),
Err(error) => {
return Err(GitSyncError::GenericError { error });
}
};
}
if !self.dir.exists() {
match std::fs::create_dir_all(&self.dir) {
Ok(_) => {}
Err(error) => {
return Err(GitSyncError::GenericError { error });
}
}
}
let url = match gix::url::parse(self.repo.as_str().into()) {
Ok(url) => url,
Err(error) => {
return Err(GitSyncError::GixParseError { error });
}
};
let mut prepare_clone = match gix::prepare_clone(url, &self.dir) {
Ok(prepared_fetch) => prepared_fetch,
Err(error) => {
return Err(GitSyncError::GixCloneError { error });
}
};
let (mut prepare_checkout, _) = match prepare_clone
.fetch_then_checkout(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)
{
Ok(checkout) => checkout,
Err(error) => {
return Err(GitSyncError::GixCloneFetchError { error });
}
};
match prepare_checkout
.main_worktree(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)
{
Ok(repository) => repository,
Err(error) => {
return Err(GitSyncError::GixCloneCheckoutError { error });
}
};
Ok(())
}
and this works well.
We also have a sync
function, which is using gix::open()
; but I can't work out how to fetch_then_checkout
on an existing repository.
I've also tried just using clone_repository
with the dir being the existing checkout, but it doesn't seem like HEAD is updated.
Any advice?
from gitoxide.
Draft PR
from gitoxide.
Thanks for trying it out!
and this works well.
Is the question-mark operation ?
forbidden in your codebase? I am pretty sure clippy
would take offence in not using it -error-handling seems unnecessarily verbose. Since it's an application, I'd recommend anyhow
as well.
We also have a
sync
function, which is usinggix::open()
; but I can't work out how tofetch_then_checkout
on an existing repository.
One cannot yet checkout into an existing repository, and I'd hope it refuses to do so into an existing non-empty directory as it would bluntly overwrite everything. It's only possible to checkout the initial clone.
It will take a while until git reset/checkout
are possible, but this PR and it's follow-ups will lead there.
from gitoxide.
Related Issues (20)
- gix-config set configuration values HOT 1
- OSS-Fuzz issue 70323 HOT 1
- Something went wrong... & Merge conflict after working on another device HOT 1
- `gix clean -xde` deletes whole repo if `.gitignore` lists `*` or `/` HOT 6
- The kstring integration in gix-attributes is unsound HOT 5
- Fallback to git commands? HOT 3
- `gix clean` with `-r` or `-xd` deletes the repo's own nested worktrees HOT 5
- audit uses of `as_ref()` and remove those that are ambiguous HOT 6
- gitoxide fails to compile with bstr 1.9.2 HOT 1
- `gix clean -xde` deletes the repo's own hidden nested worktrees, but they are not really hidden HOT 5
- The 32-bit Windows releases are 64-bit HOT 6
- Unclear intent regarding optimizations for some profiles HOT 5
- Prebuilt binaries obtained on ARM64 macOS are x86-64 HOT 5
- OSS-Fuzz issue 70841 HOT 1
- OSS-Fuzz issue 70863 HOT 1
- Release workflow relies on deprecated `set-output` feature
- OSS-Fuzz issue 70876 HOT 1
- `from_path_no_follow` test runs `touch` with nonportable date format HOT 3
- Panic when parsing `HEAD:README` in a repo with invalid HEAD. HOT 2
- gitx-credentials fails to build HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitoxide.