깃 초기화 커멘드 추가
This commit is contained in:
parent
b6ac366636
commit
88af0e5a85
4 changed files with 58 additions and 1 deletions
|
|
@ -80,6 +80,7 @@ enum CommandType {
|
|||
GitCheckout,
|
||||
GitRev,
|
||||
GitCount,
|
||||
GitReset,
|
||||
GitHub,
|
||||
GitHubPullRequestCreate,
|
||||
GitHubPullRequestList,
|
||||
|
|
@ -137,6 +138,7 @@ abstract class Command {
|
|||
CommandType.GitCheckout: () => GitCheckout(),
|
||||
CommandType.GitRev: () => GitRev(),
|
||||
CommandType.GitCount: () => GitCount(),
|
||||
CommandType.GitReset: () => GitReset(),
|
||||
CommandType.GitHub: () => GitHub(),
|
||||
CommandType.GitHubPullRequestCreate: () => GitHubPullRequestCreate(),
|
||||
CommandType.GitHubPullRequestList: () => GitHubPullRequestList(),
|
||||
|
|
@ -360,7 +362,12 @@ abstract class Command {
|
|||
}
|
||||
|
||||
Map<String, dynamic> getParam(DataCommand command) {
|
||||
var map = Command.replaceAllTagsMap(command.param);
|
||||
Map<String, dynamic> map;
|
||||
if(command.param == null) {
|
||||
map = <String, dynamic>{};
|
||||
} else {
|
||||
map = Command.replaceAllTagsMap(command.param);
|
||||
}
|
||||
map['workspace'] = _workspace = getWorkspace(map['workspace']);
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,3 +110,19 @@ class GitRev extends Command {
|
|||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
|
||||
//git 초기화
|
||||
class GitReset extends Command {
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
var data = DataGitReset.fromJson(getParam(command));
|
||||
|
||||
var shell = StringBuffer(getCDPath(workspace));
|
||||
var force = data.force! ? 'f' : '';
|
||||
shell.write(' && git reset --hard');
|
||||
shell.write(' && git clean -${force}d');
|
||||
var process = await ProcessExecutor.start(shell, printStderr: false);
|
||||
|
||||
return await completeProcess(process, command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// ignore_for_file: non_constant_identifier_names, avoid_init_to_null
|
||||
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:dart_framework/utils/slack/slack_sender.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:dart_framework/core/app_data_manager.dart';
|
||||
|
|
@ -619,6 +621,19 @@ class DataGitRev extends DataParam {
|
|||
Map<String, dynamic> toJson() => _$DataGitRevToJson(this);
|
||||
}
|
||||
|
||||
//GitReset
|
||||
@JsonSerializable()
|
||||
class DataGitReset extends DataParam {
|
||||
DataGitReset();
|
||||
|
||||
late bool? force = true;
|
||||
|
||||
factory DataGitReset.fromJson(Map<String, dynamic> json) =>
|
||||
_$DataGitResetFromJson(json);
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$DataGitResetToJson(this);
|
||||
}
|
||||
|
||||
//GitHub
|
||||
@JsonSerializable()
|
||||
class DataGitHub extends DataParam {
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ const _$CommandTypeEnumMap = {
|
|||
CommandType.GitCheckout: 'GitCheckout',
|
||||
CommandType.GitRev: 'GitRev',
|
||||
CommandType.GitCount: 'GitCount',
|
||||
CommandType.GitReset: 'GitReset',
|
||||
CommandType.GitHub: 'GitHub',
|
||||
CommandType.GitHubPullRequestCreate: 'GitHubPullRequestCreate',
|
||||
CommandType.GitHubPullRequestList: 'GitHubPullRequestList',
|
||||
|
|
@ -996,6 +997,24 @@ Map<String, dynamic> _$DataGitRevToJson(DataGitRev instance) =>
|
|||
'setValue': instance.setValue,
|
||||
};
|
||||
|
||||
DataGitReset _$DataGitResetFromJson(Map<String, dynamic> json) => DataGitReset()
|
||||
..workspace = json['workspace'] as String?
|
||||
..passExitCodes = (json['passExitCodes'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList()
|
||||
..setResult = json['setResult'] as String?
|
||||
..setExitCode = json['setExitCode'] as String?
|
||||
..force = json['force'] as bool?;
|
||||
|
||||
Map<String, dynamic> _$DataGitResetToJson(DataGitReset instance) =>
|
||||
<String, dynamic>{
|
||||
'workspace': instance.workspace,
|
||||
'passExitCodes': instance.passExitCodes,
|
||||
'setResult': instance.setResult,
|
||||
'setExitCode': instance.setExitCode,
|
||||
'force': instance.force,
|
||||
};
|
||||
|
||||
DataGitHub _$DataGitHubFromJson(Map<String, dynamic> json) => DataGitHub()
|
||||
..workspace = json['workspace'] as String?
|
||||
..passExitCodes = (json['passExitCodes'] as List<dynamic>?)
|
||||
|
|
|
|||
Loading…
Reference in a new issue