Commits

Drew Peterson committed ef36c33

Improved git support and added support for Bitbucket Teams
- Improve git support by including tag refs
- Add configuration option for bitbucket team
- If team is configured, team repositories will be downloaded rather than user repositories
- Added Team-related resource strings, even took a shot at the German (please don't laugh)
- Added *.DotSettings to hgignore to ignore resharper settings

  • Participants
  • Parent commits 680755d

Comments (0)

Files changed (11)

 *.msi
 AssemblyVersion.cs
 Thumbs.db
+*.DotSettings

File src/BitbucketBackup/App.config

       <setting name="PullTimeout" serializeAs="String">
         <value>0</value>
       </setting>
+      <setting name="TeamName" serializeAs="String">
+        <value />
+      </setting>
     </BitbucketBackup.Properties.Settings>
   </userSettings>
 </configuration>

File src/BitbucketBackup/BitbucketBackup.cs

                 }
 
                 Console.WriteLine(Resources.IntroUser, this.config.UserName);
+                if (this.config.UseTeam())
+                    Console.WriteLine(Resources.IntroTeam, this.config.TeamName);
                 Console.WriteLine(Resources.IntroFolder, this.config.BackupFolder);
                 Console.WriteLine();
                 Thread.Sleep(waitSeconds * 1000);
 
-                string resource = "users/" + this.config.UserName;
+                string user = this.config.UseTeam() ? this.config.TeamName : this.config.UserName;
+
+                string resource = String.Format("users/{0}", user);
                 string response = this.request.Execute(resource);
 
                 if (response == string.Empty)
 
                 var repos = this.parser.Parse(response);
 
-                var baseUri = new Uri("https://bitbucket.org/" + this.config.UserName + "/");
+                var baseUri = new Uri(String.Format("https://bitbucket.org/{0}/", user));
 
                 foreach (var repo in repos.OrderBy(r => r.RepoName))
                 {

File src/BitbucketBackup/Config.cs

         }
 
         /// <summary>
+        /// Bitbucket team name
+        /// </summary>
+        public string TeamName
+        {
+            get
+            {
+                return Settings.Default.TeamName;
+            }
+            private set
+            {
+                Settings.Default.TeamName = value;
+                Settings.Default.Save();
+            }
+        }
+
+        /// <summary>
+        /// Checks if the team name is set in the configuration
+        /// </summary>
+        public bool UseTeam()
+        {
+            return !String.IsNullOrEmpty(TeamName);
+        }
+
+        /// <summary>
         /// Folder on local machine where backups are saved
         /// </summary>
         public string BackupFolder
             this.PassWord = pw;
 
             Console.WriteLine();
+            Console.WriteLine(Resources.InputTeam);
+            this.TeamName = Console.ReadLine();
+
+            Console.WriteLine();
             Console.WriteLine(Resources.InputBackupFolder);
             this.BackupFolder = Console.ReadLine();
 

File src/BitbucketBackup/GitRepository.cs

-using System.IO;
+using System;
+using System.IO;
 
 namespace BitbucketBackup
 {
 
         public override void Pull()
         {
-            this.git.Execute("fetch " + this.remoteuri + " refs/heads/*:refs/heads/*");
+            this.git.Execute(String.Format("fetch {0} refs/heads/*:refs/heads/* refs/tags/*:refs/tags/*", this.remoteuri));
         }
     }
 }

File src/BitbucketBackup/IConfig.cs

         string UserName { get; }
 
         /// <summary>
+        /// Bitbucket team name
+        /// </summary>
+        string TeamName { get; }
+
+        /// <summary>
+        /// Use team name rather than username for urls
+        /// </summary>
+        bool UseTeam();
+
+        /// <summary>
         /// Folder on local machine where backups are saved
         /// </summary>
         string BackupFolder { get; }

File src/BitbucketBackup/Properties/Settings.Designer.cs

 //------------------------------------------------------------------------------
 // <auto-generated>
-//     Dieser Code wurde von einem Tool generiert.
-//     Laufzeitversion:4.0.30319.239
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.17929
 //
-//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
-//     der Code erneut generiert wird.
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
 // </auto-generated>
 //------------------------------------------------------------------------------
 
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
                 this["PullTimeout"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("")]
+        public string TeamName {
+            get {
+                return ((string)(this["TeamName"]));
+            }
+            set {
+                this["TeamName"] = value;
+            }
+        }
     }
 }

File src/BitbucketBackup/Properties/Settings.settings

     <Setting Name="PullTimeout" Type="System.Int32" Scope="User">
       <Value Profile="(Default)">0</Value>
     </Setting>
+    <Setting Name="TeamName" Type="System.String" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>

File src/BitbucketBackup/Resources.Designer.cs

 //------------------------------------------------------------------------------
 // <auto-generated>
-//     Dieser Code wurde von einem Tool generiert.
-//     Laufzeitversion:4.0.30319.269
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.17929
 //
-//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
-//     der Code erneut generiert wird.
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
 // </auto-generated>
 //------------------------------------------------------------------------------
 
     
     
     /// <summary>
-    ///   Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
     /// </summary>
-    // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
-    // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
-    // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
-    // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
         }
         
         /// <summary>
-        ///   Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+        ///   Returns the cached ResourceManager instance used by this class.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
         internal static global::System.Resources.ResourceManager ResourceManager {
         }
         
         /// <summary>
-        ///   Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
-        ///   Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
         internal static global::System.Globalization.CultureInfo Culture {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Authentication failed.
-        ///Please check if the password is valid! ähnelt.
+        ///   Looks up a localized string similar to Authentication failed.
+        ///Please check if the password is valid!.
         /// </summary>
         internal static string AuthenticationFailed {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Backup completed! ähnelt.
+        ///   Looks up a localized string similar to Backup completed!.
         /// </summary>
         internal static string BackupCompleted {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Backup failed! ähnelt.
+        ///   Looks up a localized string similar to Backup failed!.
         /// </summary>
         internal static string ClientExceptionHeadline {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Local backup folder (must already exist): ähnelt.
+        ///   Looks up a localized string similar to Local backup folder (must already exist):.
         /// </summary>
         internal static string InputBackupFolder {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die You didn&apos;t enter a backup folder (or an invalid one)! ähnelt.
+        ///   Looks up a localized string similar to You didn&apos;t enter a backup folder (or an invalid one)!.
         /// </summary>
         internal static string InputBackupFolderInvalid {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Your Bitbucket password: ähnelt.
+        ///   Looks up a localized string similar to Your Bitbucket password:.
         /// </summary>
         internal static string InputPassword {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die You didn&apos;t enter a password! ähnelt.
+        ///   Looks up a localized string similar to You didn&apos;t enter a password!.
         /// </summary>
         internal static string InputPasswordInvalid {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Timeout for pulling, in seconds:
-        ///(Mercurial only, optional, just press &lt;ENTER&gt; to use default [{0}]) ähnelt.
+        ///   Looks up a localized string similar to Timeout for pulling, in seconds:
+        ///(Mercurial only, optional, just press &lt;ENTER&gt; to use default [{0}]).
         /// </summary>
         internal static string InputPullTimeout {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Timeout for pulling must be an integer value greater than zero! ähnelt.
+        ///   Looks up a localized string similar to Timeout for pulling must be an integer value greater than zero!.
         /// </summary>
         internal static string InputPullTimeoutInvalid {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Your Bitbucket username: ähnelt.
+        ///   Looks up a localized string similar to Your Bitbucket team name (leave blank for no team):.
+        /// </summary>
+        internal static string InputTeam {
+            get {
+                return ResourceManager.GetString("InputTeam", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Your Bitbucket username:.
         /// </summary>
         internal static string InputUser {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die You didn&apos;t enter a username! ähnelt.
+        ///   Looks up a localized string similar to You didn&apos;t enter a username!.
         /// </summary>
         internal static string InputUserInvalid {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Local backup folder: {0} ähnelt.
+        ///   Looks up a localized string similar to Local backup folder: {0}.
         /// </summary>
         internal static string IntroFolder {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Bitbucket Backup {0} ähnelt.
+        ///   Looks up a localized string similar to Bitbucket Backup {0}.
         /// </summary>
         internal static string IntroHeadline {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Bitbucket user: {0} ähnelt.
+        ///   Looks up a localized string similar to Bitbucket team: {0}.
+        /// </summary>
+        internal static string IntroTeam {
+            get {
+                return ResourceManager.GetString("IntroTeam", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Bitbucket user: {0}.
         /// </summary>
         internal static string IntroUser {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Couldn&apos;t load information for user: {0}
-        ///Please check if the user name is valid! ähnelt.
+        ///   Looks up a localized string similar to Couldn&apos;t load information for user: {0}
+        ///Please check if the user name is valid!.
         /// </summary>
         internal static string InvalidUsername {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Bitbucket API didn&apos;t return a response: {0} ähnelt.
+        ///   Looks up a localized string similar to Bitbucket API didn&apos;t return a response: {0}.
         /// </summary>
         internal static string NoResponse {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Press &lt;ENTER&gt; to quit! ähnelt.
+        ///   Looks up a localized string similar to Press &lt;ENTER&gt; to quit!.
         /// </summary>
         internal static string PressEnter {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die git pull: {0} ähnelt.
+        ///   Looks up a localized string similar to git pull: {0}.
         /// </summary>
         internal static string PullingGit {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die  hg pull: {0} ähnelt.
+        ///   Looks up a localized string similar to  hg pull: {0}.
         /// </summary>
         internal static string PullingMercurial {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Timeout for pulling exceeded! ({0} seconds)  ähnelt.
+        ///   Looks up a localized string similar to Timeout for pulling exceeded! ({0} seconds) .
         /// </summary>
         internal static string PullTimeoutExceeded {
             get {
         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Press &lt;SPACE&gt; in the next {0} seconds to re-enter your settings! ähnelt.
+        ///   Looks up a localized string similar to Press &lt;SPACE&gt; in the next {0} seconds to re-enter your settings!.
         /// </summary>
         internal static string SettingsPrompt {
             get {

File src/BitbucketBackup/Resources.de.resx

   <data name="InputPullTimeoutInvalid" xml:space="preserve">
     <value>Timeout für Pulls muß eine ganze Zahl größer als 0 sein!</value>
   </data>
+  <data name="InputTeam" xml:space="preserve">
+    <value>Ihr Bitbucket-Teamnamen:</value>
+  </data>
   <data name="InputUser" xml:space="preserve">
     <value>Ihr Bitbucket-Benutzername:</value>
   </data>
   <data name="IntroFolder" xml:space="preserve">
     <value>Lokaler Backup-Ordner: {0}</value>
   </data>
+  <data name="IntroTeam" xml:space="preserve">
+    <value>Bitbucket-Team: {0}</value>
+  </data>
   <data name="IntroUser" xml:space="preserve">
     <value>Bitbucket-Benutzer: {0}</value>
   </data>

File src/BitbucketBackup/Resources.resx

   <data name="PullTimeoutExceeded" xml:space="preserve">
     <value>Timeout for pulling exceeded! ({0} seconds) </value>
   </data>
+  <data name="InputTeam" xml:space="preserve">
+    <value>Your Bitbucket team name (leave blank for no team):</value>
+  </data>
+  <data name="IntroTeam" xml:space="preserve">
+    <value>Bitbucket team: {0}</value>
+  </data>
 </root>