Добавлен флаг --snapshot для команды diff для просмотра изменений в конкретном снимке
This commit is contained in:
		
							parent
							
								
									a711af3ec8
								
							
						
					
					
						commit
						fa82b5c1eb
					
				
					 2 changed files with 45 additions and 10 deletions
				
			
		
							
								
								
									
										14
									
								
								source/app.d
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								source/app.d
									
										
									
									
									
								
							| 
						 | 
					@ -39,7 +39,15 @@ int main(string[] args)
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
		.add(new Command("status", "Checking the status of tracked files"))
 | 
							.add(new Command("status", "Checking the status of tracked files"))
 | 
				
			||||||
		.add(new Command("diff", "Show changed data"))
 | 
							.add(new Command("diff", "Show changed data")
 | 
				
			||||||
 | 
								.add(new Option("s", "snapshot", "Specify snapshot hash")
 | 
				
			||||||
 | 
									.optional
 | 
				
			||||||
 | 
									.validateEachWith(
 | 
				
			||||||
 | 
										opt => opt.isValidHash,
 | 
				
			||||||
 | 
										"must contain snapshot hash provided"
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
 | 
								)
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
		.add(new Command("size", "Size of snapshots"))
 | 
							.add(new Command("size", "Size of snapshots"))
 | 
				
			||||||
		.add(new Command("import", "Import snapshot from a tar.gz archive")
 | 
							.add(new Command("import", "Import snapshot from a tar.gz archive")
 | 
				
			||||||
			.add(new Argument("archive", "The path to the tar.gz archive file").required)
 | 
								.add(new Argument("archive", "The path to the tar.gz archive file").required)
 | 
				
			||||||
| 
						 | 
					@ -167,7 +175,9 @@ int main(string[] args)
 | 
				
			||||||
				snag.initialize(init.flag("force"))
 | 
									snag.initialize(init.flag("force"))
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
			.on("diff", diff =>
 | 
								.on("diff", diff =>
 | 
				
			||||||
				snag.diff()
 | 
									snag.diff(
 | 
				
			||||||
 | 
										diff.option("snapshot", "")
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
			.on("size", size =>
 | 
								.on("size", size =>
 | 
				
			||||||
				snag.size()
 | 
									snag.size()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,16 +292,41 @@ class Snag {
 | 
				
			||||||
		writeln("Backup was restored successfully: ", hash);
 | 
							writeln("Backup was restored successfully: ", hash);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void diff() {
 | 
						void diff(string hash) {
 | 
				
			||||||
		auto result = git(
 | 
							string[] result;
 | 
				
			||||||
			["diff"],
 | 
							if (hash.length) {
 | 
				
			||||||
			"Failed to retrieve changes"
 | 
								git(
 | 
				
			||||||
		);
 | 
									["rev-parse", hash],
 | 
				
			||||||
		if (result.output.length) {
 | 
									"This snapshot is not available in the archive"
 | 
				
			||||||
			result.output.write;
 | 
								);
 | 
				
			||||||
 | 
								result = git(
 | 
				
			||||||
 | 
									["show", hash, "--name-only", "--pretty="],
 | 
				
			||||||
 | 
									"Failed to retrieve snapshot information"
 | 
				
			||||||
 | 
								).output.split('\n').filter!(p => !p.empty).array;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								result = git(
 | 
				
			||||||
 | 
									["diff", "--name-only"],
 | 
				
			||||||
 | 
									"Failed to retrieve changes"
 | 
				
			||||||
 | 
								).output.split('\n').filter!(p => !p.empty).array;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (!result.length) {
 | 
				
			||||||
 | 
								writeln("No changes at the moment");
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		writeln("No changes at the moment");
 | 
							if (hash.length)
 | 
				
			||||||
 | 
								result.each!(e =>
 | 
				
			||||||
 | 
									git(
 | 
				
			||||||
 | 
										["show", "--pretty=", hash, "--", e],
 | 
				
			||||||
 | 
										"Failed to retrieve file information"
 | 
				
			||||||
 | 
									).output.write
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								result.each!(e =>
 | 
				
			||||||
 | 
									git(
 | 
				
			||||||
 | 
										["diff", e],
 | 
				
			||||||
 | 
										"Failed to retrieve file information"
 | 
				
			||||||
 | 
									).output.write
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void exportSnapshot(string path, string hash) {
 | 
						void exportSnapshot(string path, string hash) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue