use bytes::Bytes;
use thrussh::{server::Session, ChannelId};
use tracing::instrument;
use crate::{
protocol::{low_level::HashOutput, packet_line::PktLine},
Handler, PackageProvider, UserProvider,
};
#[instrument(skip(handle, session, channel, _metadata, commit_hash), err)]
pub fn handle<U: UserProvider + PackageProvider + Send + Sync + 'static>(
handle: &mut Handler<U>,
session: &mut Session,
channel: ChannelId,
_metadata: &[Bytes],
commit_hash: &HashOutput,
) -> Result<(), anyhow::Error> {
let commit_hash = hex::encode(&commit_hash);
handle.write(PktLine::Data(
format!("{} HEAD symref-target:refs/heads/master", commit_hash).as_bytes(),
))?;
handle.write(PktLine::Flush)?;
handle.flush(session, channel);
Ok(())
}