Skip to content
Snippets Groups Projects
Commit c81b8f78 authored by Georges Racinet's avatar Georges Racinet
Browse files

RHGitaly: reading the GitLab default branch file

As noted in comment, this should really be in the `store` subdirectory,
but that is a fight (data migration) for another day.
parent 2c80b078
No related branches found
No related tags found
2 merge requests!169Protocol v15.9 and stable branch merge",!164RHGitaly CommitService.FindCommit implementation
......@@ -35,7 +35,7 @@
use bytes::{Bytes, BytesMut};
use std::io;
use std::path::Path;
use tokio::fs::File;
use tokio::fs::{read, File};
use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncReadExt, BufReader};
use tokio_stream::wrappers::LinesStream;
use tokio_stream::StreamExt;
......@@ -87,6 +87,18 @@
InvalidNode(Vec<u8>),
}
/// Read the GitLab default branch information
///
/// This notion is stateful and repository specific (can be tweaked by users). It is independent
/// from what Git and Mercurial would consider to be the default branch (a global setting at most).
pub async fn get_gitlab_default_branch(
store_vfs: &Path,
) -> Result<Option<Vec<u8>>, StateFileError> {
// Yes `..` is ugly, but in truth that file should be in the `store/` subdirectory
let path = store_vfs.join("../default_gitlab_branch");
Ok(io_error_not_found_as_none(read(&path).await)?)
}
/// A [`Decoder`] for the typed refs file format, allowing to stream [`TypedRef`]s.
///
/// This can be used with [`FramedRead`] to turn any [`AsyncRead`]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment