Skip to content

Commit

Permalink
[clone] first journey test for pack-receive
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Sep 11, 2020
1 parent d9ced27 commit 46a3511
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/plumbing/lean/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub struct RemoteRefList {
#[argh(subcommand, name = "pack-receive")]
pub struct PackReceive {
/// the protocol version to use. Valid values are 1 and 2
#[argh(option)]
#[argh(option, short = 'p')]
pub protocol: Option<core::Protocol>,

/// the URLs or path from which to receive the pack.
Expand Down
24 changes: 24 additions & 0 deletions src/plumbing/pretty/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@ pub fn main() -> Result<()> {
git_features::interrupt::init_handler(std::io::stderr());

match cmd {
Subcommands::PackReceive {
protocol,
url,
directory,
} => prepare_and_run(
"pack-receive",
verbose,
progress,
progress_keep_open,
core::pack::receive::PROGRESS_RANGE,
move |progress, out, _err| {
core::pack::receive(
protocol,
&url,
directory,
git_features::progress::DoOrDiscard::from(progress),
core::pack::receive::Context {
thread_limit,
format,
out,
},
)
},
),
Subcommands::RemoteRefList { protocol, url } => prepare_and_run(
"remote-ref-list",
verbose,
Expand Down
17 changes: 17 additions & 0 deletions src/plumbing/pretty/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ pub struct Args {

#[derive(Debug, Clap)]
pub enum Subcommands {
#[clap(setting = AppSettings::ColoredHelp)]
#[clap(setting = AppSettings::DisableVersion)]
PackReceive {
/// The protocol version to use. Valid values are 1 and 2
#[clap(long, short = "p")]
protocol: Option<core::Protocol>,

/// The URLs or path from which to receive the pack.
///
/// See here for a list of supported URLs: https://www.git-scm.com/docs/git-clone#_git_urls
url: String,

/// The directory into which to write the received pack and index.
///
/// If unset, they will be discarded.
directory: Option<PathBuf>,
},
/// List remote references from a remote identified by a url.
///
/// This is the plumbing equivalent of `git ls-remote`.
Expand Down
1 change: 1 addition & 0 deletions tests/snapshots/plumbing/pack-receive/file-v-any
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Outcome { index: Outcome { index_kind: V2, index_hash: Id([199, 135, 222, 42, 175, 184, 151, 65, 124, 168, 22, 123, 174, 177, 70, 234, 189, 24, 188, 95]), data_hash: Id([52, 101, 116, 183, 51, 29, 195, 161, 114, 77, 162, 24, 214, 34, 198, 225, 182, 198, 106, 87]), num_objects: 9 }, pack_kind: V2, index_path: None, data_path: None }
65 changes: 42 additions & 23 deletions tests/stateless-journey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,52 @@ title "CLI ${kind}"
)
)

function small-repo-in-sandbox() {
sandbox
{
git init
git config commit.gpgsign false
set -a
export GIT_AUTHOR_DATE="2020-09-09 09:06:03 +0800"
export GIT_COMMITTER_DATE="${GIT_AUTHOR_DATE}"
export GIT_AUTHOR_NAME="Sebastian Thiel"
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
touch a
git add a
git commit -m "first"
git tag unannotated
touch b
git add b
git commit -m "second"
git tag annotated -m "tag message"
git branch dev
echo hi >> b
git commit -am "third"
} &>/dev/null
}

title plumbing
snapshot="$snapshot/plumbing"
(when "running 'pack-receive'"
snapshot="$snapshot/pack-receive"
(small-repo-in-sandbox
(with "file:// protocol"
(with "version 1"
(with "no output directory"
it "generates the correct output" && {
WITH_SNAPSHOT="$snapshot/file-v-any" \
expect_run $SUCCESSFULLY "$exe_plumbing" pack-receive -p 1 .git
}
)
)
)
)
)
(when "running 'remote-ref-list'"
snapshot="$snapshot/remote-ref-list"
(sandbox
{
git init
git config commit.gpgsign false
set -a
export GIT_AUTHOR_DATE="2020-09-09 09:06:03 +0800"
export GIT_COMMITTER_DATE="${GIT_AUTHOR_DATE}"
export GIT_AUTHOR_NAME="Sebastian Thiel"
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
touch a
git add a
git commit -m "first"
git tag unannotated
touch b
git add b
git commit -m "second"
git tag annotated -m "tag message"
git branch dev
echo hi >> b
git commit -am "third"
} &>/dev/null
(small-repo-in-sandbox
(with "file:// protocol"
(with "version 1"
it "generates the correct output" && {
Expand Down

0 comments on commit 46a3511

Please sign in to comment.