mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat: update config example
This commit is contained in:
parent
aa5815ff27
commit
53fe671bff
1 changed files with 45 additions and 9 deletions
|
@ -3,15 +3,51 @@ import 'package:libgit2dart/libgit2dart.dart';
|
||||||
void main() {
|
void main() {
|
||||||
final repoConfig = Config(path: '.git/config');
|
final repoConfig = Config(path: '.git/config');
|
||||||
|
|
||||||
final isBare = repoConfig.getBool('core.bare');
|
print('All entries of repo config:');
|
||||||
final isLoggingAllRefUpdates = repoConfig.getBool('core.logallrefupdates');
|
for (final entry in repoConfig.entries.entries) {
|
||||||
final repoFormatVersion = repoConfig.getInt('core.repositoryformatversion');
|
print('${entry.key}: ${entry.value}');
|
||||||
final remoteOriginUrl = repoConfig.getString('remote.origin.url');
|
}
|
||||||
|
|
||||||
print('Repository is bare = $isBare');
|
|
||||||
print('Logging all ref updates = $isLoggingAllRefUpdates');
|
|
||||||
print('Repository format version = $repoFormatVersion');
|
|
||||||
print('Remote origin url = $remoteOriginUrl');
|
|
||||||
|
|
||||||
repoConfig.close();
|
repoConfig.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
final systemConfig = Config.system();
|
||||||
|
|
||||||
|
print(
|
||||||
|
'\nUser Name from system config: ${systemConfig.entries['user.name']}');
|
||||||
|
|
||||||
|
systemConfig.close();
|
||||||
|
} catch (e) {
|
||||||
|
print('\n$e');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final globalConfig = Config.global();
|
||||||
|
|
||||||
|
print(
|
||||||
|
'\nUser Name from global config: ${globalConfig.entries['user.name']}');
|
||||||
|
|
||||||
|
globalConfig.close();
|
||||||
|
} catch (e) {
|
||||||
|
print('\n$e');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final xdgConfig = Config.xdg();
|
||||||
|
print('\nAll entries of repo config:');
|
||||||
|
|
||||||
|
print('\nUser Name from xdg config: ${xdgConfig.entries['user.name']}');
|
||||||
|
|
||||||
|
xdgConfig.close();
|
||||||
|
} catch (e) {
|
||||||
|
print('\n$e');
|
||||||
|
}
|
||||||
|
|
||||||
|
final config = Config();
|
||||||
|
|
||||||
|
print('\nAll entries of system/global config:');
|
||||||
|
for (final entry in config.entries.entries) {
|
||||||
|
print('${entry.key}: ${entry.value}');
|
||||||
|
}
|
||||||
|
config.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue