You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RepositoryConfig.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com>
  3. * Copyright (C) 2007, Dave Watson <dwatson@mimvista.com>
  4. * Copyright (C) 2008-2009, Google Inc.
  5. * Copyright (C) 2009, JetBrains s.r.o.
  6. * Copyright (C) 2007-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
  7. * Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org>
  8. * Copyright (C) 2008, Thad Hughes <thadh@thad.corp.google.com>
  9. * Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
  10. * and other copyright owners as documented in the project's IP log.
  11. *
  12. * This program and the accompanying materials are made available
  13. * under the terms of the Eclipse Distribution License v1.0 which
  14. * accompanies this distribution, is reproduced below, and is
  15. * available at http://www.eclipse.org/org/documents/edl-v10.php
  16. *
  17. * All rights reserved.
  18. *
  19. * Redistribution and use in source and binary forms, with or
  20. * without modification, are permitted provided that the following
  21. * conditions are met:
  22. *
  23. * - Redistributions of source code must retain the above copyright
  24. * notice, this list of conditions and the following disclaimer.
  25. *
  26. * - Redistributions in binary form must reproduce the above
  27. * copyright notice, this list of conditions and the following
  28. * disclaimer in the documentation and/or other materials provided
  29. * with the distribution.
  30. *
  31. * - Neither the name of the Eclipse Foundation, Inc. nor the
  32. * names of its contributors may be used to endorse or promote
  33. * products derived from this software without specific prior
  34. * written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  37. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  38. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  39. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  41. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  43. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  44. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  45. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  46. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  47. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  48. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. */
  50. package org.eclipse.jgit.lib;
  51. import java.io.File;
  52. /**
  53. * An object representing the Git config file.
  54. *
  55. * This can be either the repository specific file or the user global
  56. * file depending on how it is instantiated.
  57. */
  58. public class RepositoryConfig extends FileBasedConfig {
  59. /** Section name for a branch configuration. */
  60. public static final String BRANCH_SECTION = "branch";
  61. /**
  62. * Create a Git configuration file reader/writer/cache for a specific file.
  63. *
  64. * @param base
  65. * configuration that provides default values if this file does
  66. * not set/override a particular key. Often this is the user's
  67. * global configuration file, or the system level configuration.
  68. * @param cfgLocation
  69. * path of the file to load (or save).
  70. */
  71. public RepositoryConfig(final Config base, final File cfgLocation) {
  72. super(base, cfgLocation);
  73. }
  74. /**
  75. * @return Core configuration values
  76. */
  77. public CoreConfig getCore() {
  78. return get(CoreConfig.KEY);
  79. }
  80. /**
  81. * @return transfer, fetch and receive configuration values
  82. */
  83. public TransferConfig getTransfer() {
  84. return get(TransferConfig.KEY);
  85. }
  86. /** @return standard user configuration data */
  87. public UserConfig getUserConfig() {
  88. return get(UserConfig.KEY);
  89. }
  90. /**
  91. * @return the author name as defined in the git variables
  92. * and configurations. If no name could be found, try
  93. * to use the system user name instead.
  94. */
  95. public String getAuthorName() {
  96. return getUserConfig().getAuthorName();
  97. }
  98. /**
  99. * @return the committer name as defined in the git variables
  100. * and configurations. If no name could be found, try
  101. * to use the system user name instead.
  102. */
  103. public String getCommitterName() {
  104. return getUserConfig().getCommitterName();
  105. }
  106. /**
  107. * @return the author email as defined in git variables and
  108. * configurations. If no email could be found, try to
  109. * propose one default with the user name and the
  110. * host name.
  111. */
  112. public String getAuthorEmail() {
  113. return getUserConfig().getAuthorEmail();
  114. }
  115. /**
  116. * @return the committer email as defined in git variables and
  117. * configurations. If no email could be found, try to
  118. * propose one default with the user name and the
  119. * host name.
  120. */
  121. public String getCommitterEmail() {
  122. return getUserConfig().getCommitterEmail();
  123. }
  124. }