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> {
92
92
pub fn publish ( ws : & Workspace < ' _ > , opts : & PublishOpts < ' _ > ) -> CargoResult < ( ) > {
93
93
let specs = opts. to_publish . to_package_id_specs ( ws) ?;
94
94
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" )
104
96
}
105
- if Packages :: Packages ( vec ! [ ] ) ! = opts. to_publish && ws. is_virtual ( ) {
97
+ if Packages :: Default = = opts. to_publish && ws. is_virtual ( ) {
106
98
bail ! ( "the `-p` argument must be specified in the root of a virtual workspace" )
107
99
}
108
100
let member_ids = ws. members ( ) . map ( |p| p. package_id ( ) ) ;
109
101
// Check that the spec matches exactly one member.
110
102
specs[ 0 ] . query ( member_ids) ?;
111
103
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)
113
105
// So we need filter
114
106
pkgs = pkgs
115
107
. into_iter ( )
Original file line number Diff line number Diff line change @@ -1754,7 +1754,7 @@ fn with_duplicate_spec_in_members() {
1754
1754
p. cargo ( "publish --no-verify --token sekrit" )
1755
1755
. with_status ( 101 )
1756
1756
. 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" ,
1758
1758
)
1759
1759
. run ( ) ;
1760
1760
}
@@ -1837,6 +1837,56 @@ fn in_virtual_workspace() {
1837
1837
. run ( ) ;
1838
1838
}
1839
1839
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
+
1840
1890
#[ cargo_test]
1841
1891
fn in_package_workspace_not_found ( ) {
1842
1892
registry:: init ( ) ;
You can’t perform that action at this time.
0 commit comments