File tree Expand file tree Collapse file tree 2 files changed +54
-12
lines changed
Expand file tree Collapse file tree 2 files changed +54
-12
lines changed Original file line number Diff line number Diff line change @@ -92,24 +92,16 @@ pub struct PublishOpts<'cfg> {
9292pub fn publish ( ws : & Workspace < ' _ > , opts : & PublishOpts < ' _ > ) -> CargoResult < ( ) > {
9393 let specs = opts. to_publish . to_package_id_specs ( ws) ?;
9494 if specs. len ( ) > 1 {
95- match opts. to_publish {
96- Packages :: Default => {
97- bail ! ( "must be specified to select a single package to publish. Check `default-members` or using `-p` argument" )
98- }
99- Packages :: Packages ( _) => {
100- bail ! ( "the `-p` argument must be specified to select a single package to publish" )
101- }
102- _ => { }
103- }
95+ bail ! ( "the `-p` argument must be specified to select a single package to publish" )
10496 }
105- if Packages :: Packages ( vec ! [ ] ) ! = opts. to_publish && ws. is_virtual ( ) {
97+ if Packages :: Default = = opts. to_publish && ws. is_virtual ( ) {
10698 bail ! ( "the `-p` argument must be specified in the root of a virtual workspace" )
10799 }
108100 let member_ids = ws. members ( ) . map ( |p| p. package_id ( ) ) ;
109101 // Check that the spec matches exactly one member.
110102 specs[ 0 ] . query ( member_ids) ?;
111103 let mut pkgs = ws. members_with_features ( & specs, & opts. cli_features ) ?;
112- // In `members_with_features_old`, it will add "current" package(determined by the cwd). Line:1455 in workspace.rs.
104+ // In `members_with_features_old`, it will add "current" package (determined by the cwd)
113105 // So we need filter
114106 pkgs = pkgs
115107 . into_iter ( )
Original file line number Diff line number Diff line change @@ -1754,7 +1754,7 @@ fn with_duplicate_spec_in_members() {
17541754 p. cargo ( "publish --no-verify --token sekrit" )
17551755 . with_status ( 101 )
17561756 . with_stderr (
1757- "error: must be specified to select a single package to publish. Check `default-members` or using `-p` argument " ,
1757+ "error: the `-p` argument must be specified to select a single package to publish" ,
17581758 )
17591759 . run ( ) ;
17601760}
@@ -1837,6 +1837,56 @@ fn in_virtual_workspace() {
18371837 . run ( ) ;
18381838}
18391839
1840+ #[ cargo_test]
1841+ fn in_virtual_workspace_with_p ( ) {
1842+ registry:: init ( ) ;
1843+
1844+ let p = project ( )
1845+ . file (
1846+ "Cargo.toml" ,
1847+ r#"
1848+ [workspace]
1849+ members = ["foo","li"]
1850+ "# ,
1851+ )
1852+ . file (
1853+ "foo/Cargo.toml" ,
1854+ r#"
1855+ [project]
1856+ name = "foo"
1857+ version = "0.0.1"
1858+ authors = []
1859+ license = "MIT"
1860+ description = "foo"
1861+ "# ,
1862+ )
1863+ . file ( "foo/src/main.rs" , "fn main() {}" )
1864+ . file (
1865+ "li/Cargo.toml" ,
1866+ r#"
1867+ [package]
1868+ name = "li"
1869+ version = "0.0.1"
1870+ description = "li"
1871+ license = "MIT"
1872+ "# ,
1873+ )
1874+ . file ( "li/src/main.rs" , "fn main() {}" )
1875+ . build ( ) ;
1876+
1877+ p. cargo ( "publish -p li --no-verify --token sekrit" )
1878+ . with_stderr (
1879+ "\
1880+ [UPDATING] [..]
1881+ [WARNING] manifest has no documentation, homepage or repository.
1882+ See [..]
1883+ [PACKAGING] li v0.0.1 ([CWD]/li)
1884+ [UPLOADING] li v0.0.1 ([CWD]/li)
1885+ " ,
1886+ )
1887+ . run ( ) ;
1888+ }
1889+
18401890#[ cargo_test]
18411891fn in_package_workspace_not_found ( ) {
18421892 registry:: init ( ) ;
You can’t perform that action at this time.
0 commit comments