git-reclone 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d7a5a34e55842b68937ef1bf93521b7a07e4b2dfa8c13b2c4d7796a80c66602
4
- data.tar.gz: 5c9e66b1ae1d394434a57d65b0e2998b5f82d062591f6750db97015b7b71a826
3
+ metadata.gz: 98a27fe2203a4ee3b2a3a59ceb3ee3dc3119b9f900238a8c7273307dea196730
4
+ data.tar.gz: 287d77e58954e169186dbca7c6c84867d8bf0130499252f77f581796a8015d65
5
5
  SHA512:
6
- metadata.gz: 7807f4738bbe02ffff7f0a424bfd43896e2d293d0eb7169b431fcb79e48257b6b1abda8762928453303a6553ad71965f6dbb08071558b30699097bd26205cc2d
7
- data.tar.gz: 6405463051f049349651d27177902ef6f1b0e7a38f54ac6858681ebbdc826c61f2940b8fb7150dd2adeaf1f6360eeb7b057bd2b7a2535a59e48ebb059ea1a48c
6
+ metadata.gz: 993b7033da1e2d1b9a9a6418abf842d11578ed5e60f04310b0d9400e406cd1886f1f05debf564a45ef990c0055bc7ce6ecfb44688dc9754b638dfeec1d50a188
7
+ data.tar.gz: 734de94a6cd4a524af501ad9381b20a95f9684af283f781623e8f048716cfa181cc8c44ecdf6289d8ef6e63fda5b8004ea2b1a121a70034ff445db70a9ba2daf
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2026-02-08
9
+
10
+ ### Added
11
+ - **Safe clone mechanism**: Repository now clones to a temporary directory first, only replacing the local copy after successful clone. This protects your local data if the clone fails for any reason.
12
+ - **Automatic branch restoration**: After recloning, the tool automatically checks out your original branch if it exists on the remote.
13
+ - **StandardRB linting**: Added StandardRB as a code linter with rake integration and Travis CI checks.
14
+ - **Comprehensive test suite**: Added tests for temp directory cleanup, failed clone handling, and branch restoration.
15
+ - **Modern git platform support**: Added support for Gitea and Gogs in addition to GitHub and Bitbucket.
16
+ - **Local assets**: Moved screencast from Imgur to local `assets/` folder in the repository.
17
+
18
+ ### Changed
19
+ - **Updated documentation**: Changed language from "destroy" to "replace" to better reflect the safer behavior.
20
+ - **Warning messages**: Updated user-facing messages to accurately describe the safe clone-to-temp-first approach.
21
+ - **Test repository**: Switched test suite to use GitHub's official `octocat/Hello-World` repository for better reliability.
22
+ - **Branch references**: Updated from `master` to `main` to reflect modern Git conventions.
23
+ - **Constant naming**: Renamed `Version` and `Help` to `VERSION` and `HELP` to follow Ruby naming conventions.
24
+ - **Gemspec improvements**:
25
+ - Added distinct summary and description
26
+ - Added bounded version constraints for all dependencies
27
+ - Improved description to highlight safety features
28
+
29
+ ### Removed
30
+ - **Ronn dependency**: Removed unused documentation generation dependency.
31
+ - **Heroku references**: Replaced with modern self-hosted Git platforms (Gitea, Gogs).
32
+
33
+ ### Fixed
34
+ - **Credential prompting**: Added `GIT_TERMINAL_PROMPT=0` to prevent interactive credential prompts during tests.
35
+ - **Test output**: Suppressed git clone progress output to keep test output clean.
36
+ - **All linting issues**: Fixed code style issues to comply with StandardRB.
37
+
38
+ ### Security
39
+ - **Safer reclone process**: Local repository is now preserved if remote clone fails, preventing data loss.
40
+
41
+ ## [0.2.3] - Previous Release
42
+ - Legacy version before major safety improvements
43
+
44
+ [1.0.0]: https://github.com/jeremywrnr/git-reclone/compare/v0.2.3...v1.0.0
data/bin/git-reclone CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "git-reclone"
4
+ require 'git_reclone'
4
5
 
5
6
  # git-reclone by jeremy warner
6
7
  # easily reset git repo from remotes
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # universal version tracking
2
4
 
3
5
  class GitReclone
4
- VERSION = "1.0.0"
6
+ VERSION = '1.0.1'
5
7
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # git-reclone gem
2
4
  # jeremy warner
3
5
 
4
- # todo: add an option to automatically add a backup of the local copy
6
+ # TODO: add an option to automatically add a backup of the local copy
5
7
  # todo: add all remotes other than the origins, maintain connections
6
8
  # todo: -b / --backup, and this actually should be the default (maybe)
7
9
 
8
- require "colored"
9
- require "fileutils"
10
- require "tmpdir"
11
- require "git-reclone-version"
10
+ require 'colored'
11
+ require 'fileutils'
12
+ require 'tmpdir'
13
+ require_relative 'git_reclone/version'
12
14
 
13
15
  class GitReclone
14
16
  def initialize(test = false)
@@ -18,7 +20,7 @@ class GitReclone
18
20
  end
19
21
 
20
22
  def fire(args = [])
21
- opts = args.select { |a| a[0] == "-" }
23
+ opts = args.select { |a| a[0] == '-' }
22
24
  opts.each { |o| parse_opt o }
23
25
  exit 0 if @testing || opts.first
24
26
  parse_arg((args - opts).first)
@@ -31,11 +33,11 @@ class GitReclone
31
33
 
32
34
  def parse_opt(o)
33
35
  case o
34
- when "--force", "-f"
36
+ when '--force', '-f'
35
37
  @verify = false
36
- when "--help", "-h"
38
+ when '--help', '-h'
37
39
  puts GitReclone::HELP
38
- when "--version", "-v"
40
+ when '--version', '-v'
39
41
  puts GitReclone::VERSION
40
42
  end
41
43
  end
@@ -46,7 +48,7 @@ class GitReclone
46
48
 
47
49
  def no_repo?
48
50
  `git status 2>&1`.split("\n").first ==
49
- "fatal: Not a git repository (or any of the parent directories): .git"
51
+ 'fatal: Not a git repository (or any of the parent directories): .git'
50
52
  end
51
53
 
52
54
  def git_root
@@ -62,9 +64,9 @@ class GitReclone
62
64
  end
63
65
 
64
66
  def reclonebanner
65
- 25.times { |x| slowp "\rpreparing| ".red << "~" * x << "#==>".red }
66
- 25.times { |x| slowp "\rpreparing| ".red << " " * x << "~" * (25 - x) << "#==>".yellow }
67
- printf "\rREADY.".red << " " * 50 << "\n"
67
+ 25.times { |x| slowp "\rpreparing| ".red << ('~' * x) << '#==>'.red }
68
+ 25.times { |x| slowp "\rpreparing| ".red << (' ' * x) << ('~' * (25 - x)) << '#==>'.yellow }
69
+ printf "\rREADY.".red << (' ' * 50) << "\n"
68
70
  end
69
71
 
70
72
  def slowp(x)
@@ -74,11 +76,11 @@ class GitReclone
74
76
 
75
77
  # trying to parse out which remote should be the new source
76
78
  def remote(search = /.*/)
77
- pexit "Not currently in a git repository.".yellow if no_repo?
79
+ pexit 'Not currently in a git repository.'.yellow if no_repo?
78
80
 
79
81
  r = remotes.find { |gr| gr.match search }
80
82
 
81
- pexit "No remotes found in this repository.".yellow if remotes.nil?
83
+ pexit 'No remotes found in this repository.'.yellow if remotes.nil?
82
84
 
83
85
  if r.nil?
84
86
  errmsg = "No remotes found that match #{search.to_s.red}. All remotes:\n" + remotes.join("\n")
@@ -96,13 +98,13 @@ class GitReclone
96
98
  puts "Local target:\t".red << git_root
97
99
 
98
100
  branch = current_branch
99
- puts "Current branch:\t".red << branch unless branch == "HEAD"
101
+ puts "Current branch:\t".red << branch unless branch == 'HEAD'
100
102
 
101
103
  if @verify
102
- puts "Warning: this will replace the local copy with a fresh clone from the remote.".yellow
103
- printf "Continue recloning local repo? [yN] ".yellow
104
- unless $stdin.gets.chomp.downcase[0] == "y"
105
- puts "Reclone aborted.".green
104
+ puts 'Warning: this will replace the local copy with a fresh clone from the remote.'.yellow
105
+ printf 'Continue recloning local repo? [yN] '.yellow
106
+ unless $stdin.gets.chomp.downcase[0] == 'y'
107
+ puts 'Reclone aborted.'.green
106
108
  return
107
109
  end
108
110
  end
@@ -113,7 +115,7 @@ class GitReclone
113
115
  # overwrite the local copy of the repository with the remote one
114
116
  def reclone(remote, root, branch = nil)
115
117
  # create a temporary directory for cloning
116
- temp_dir = Dir.mktmpdir("git-reclone-")
118
+ temp_dir = Dir.mktmpdir('git-reclone-')
117
119
 
118
120
  begin
119
121
  # clone into temp directory (disable credential prompts)
@@ -121,41 +123,42 @@ class GitReclone
121
123
 
122
124
  if system(cloner)
123
125
  # clone succeeded, now replace the local copy
124
- if !@testing
125
- tree = Dir.glob("*", File::FNM_DOTMATCH).select { |d| ![".", ".."].include? d }
126
+ unless @testing
127
+ tree = Dir.glob('*', File::FNM_DOTMATCH).reject { |d| ['.', '..'].include? d }
126
128
  FileUtils.rmtree(tree)
127
129
 
128
130
  # move contents from temp to root
129
131
  Dir.glob("#{temp_dir}/*", File::FNM_DOTMATCH).each do |item|
130
- next if File.basename(item) == "." || File.basename(item) == ".."
132
+ next if ['.', '..'].include?(File.basename(item))
133
+
131
134
  FileUtils.mv(item, root)
132
135
  end
133
136
 
134
137
  # restore original branch if it exists
135
- if branch && branch != "HEAD"
138
+ if branch && branch != 'HEAD'
136
139
  Dir.chdir(root) do
137
140
  system("git checkout #{branch} > /dev/null 2>&1")
138
141
  end
139
142
  end
140
143
  end
141
144
 
142
- puts "Recloned successfully.".green
143
- "Recloned successfully.".green
145
+ puts 'Recloned successfully.'.green
146
+ 'Recloned successfully.'.green
144
147
  else
145
148
  # clone failed
146
- puts "Clone failed.".red
149
+ puts 'Clone failed.'.red
147
150
  nil
148
151
  end
149
152
  ensure
150
153
  # always clean up temp directory
151
- FileUtils.rm_rf(temp_dir) if Dir.exist?(temp_dir)
154
+ FileUtils.rm_rf(temp_dir)
152
155
  end
153
156
  end
154
157
  end
155
158
 
156
- GitReclone::HELP = <<~HELP
157
- #{"git reclone".red}: a git repo restoring tool
158
-
159
+ GitReclone::HELP = <<~HELP.freeze
160
+ #{'git reclone'.red}: a git repo restoring tool
161
+
159
162
  replaces your local copy with a fresh clone from the remote.
160
163
  clones to a temp directory first, so your local copy is safe if the clone fails.
161
164
  to restore from a particular remote repository, specify the host:
data/readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # git-reclone :rocket:
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/git-reclone.svg)](https://badge.fury.io/rb/git-reclone)
4
- [![Build Status](https://app.travis-ci.com/jeremywrnr/git-reclone.svg)](https://app.travis-ci.com/github/jeremywrnr/git-reclone)
4
+ [![CI](https://github.com/jeremywrnr/git-reclone/actions/workflows/ci.yml/badge.svg)](https://github.com/jeremywrnr/git-reclone/actions/workflows/ci.yml)
5
5
  [![MIT](https://img.shields.io/npm/l/alt.svg?style=flat)](http://jeremywrnr.com/mit-license)
6
6
 
7
7
  replace your local copy of a git repo with a fresh clone from your remote.
@@ -55,5 +55,5 @@ meant for?
55
55
  ## testing
56
56
 
57
57
  bundle || gem install bundler && bundle
58
- rake # running git-reclone's tests
58
+ just spec # running git-reclone's tests
59
59
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-reclone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Warner
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-02-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: colored
@@ -30,20 +29,6 @@ dependencies:
30
29
  - - "~>"
31
30
  - !ruby/object:Gem::Version
32
31
  version: '1.2'
33
- - !ruby/object:Gem::Dependency
34
- name: rake
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '13.0'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '13.0'
47
32
  - !ruby/object:Gem::Dependency
48
33
  name: rspec
49
34
  requirement: !ruby/object:Gem::Requirement
@@ -59,19 +44,19 @@ dependencies:
59
44
  - !ruby/object:Gem::Version
60
45
  version: '3.0'
61
46
  - !ruby/object:Gem::Dependency
62
- name: standard
47
+ name: simplecov
63
48
  requirement: !ruby/object:Gem::Requirement
64
49
  requirements:
65
50
  - - "~>"
66
51
  - !ruby/object:Gem::Version
67
- version: '1.0'
52
+ version: 0.22.0
68
53
  type: :development
69
54
  prerelease: false
70
55
  version_requirements: !ruby/object:Gem::Requirement
71
56
  requirements:
72
57
  - - "~>"
73
58
  - !ruby/object:Gem::Version
74
- version: '1.0'
59
+ version: 0.22.0
75
60
  description: A tool to safely replace your local git repository with a fresh clone
76
61
  from the remote. Clones to a temporary directory first to protect your local copy
77
62
  if something goes wrong, and automatically restores your current branch.
@@ -81,15 +66,15 @@ executables:
81
66
  extensions: []
82
67
  extra_rdoc_files: []
83
68
  files:
69
+ - CHANGELOG.md
84
70
  - bin/git-reclone
85
- - lib/git-reclone-version.rb
86
- - lib/git-reclone.rb
71
+ - lib/git_reclone.rb
72
+ - lib/git_reclone/version.rb
87
73
  - readme.md
88
74
  homepage: http://github.com/jeremywrnr/git-reclone
89
75
  licenses:
90
76
  - MIT
91
77
  metadata: {}
92
- post_install_message:
93
78
  rdoc_options: []
94
79
  require_paths:
95
80
  - lib
@@ -97,15 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
82
  requirements:
98
83
  - - ">="
99
84
  - !ruby/object:Gem::Version
100
- version: '0'
85
+ version: '3.1'
101
86
  required_rubygems_version: !ruby/object:Gem::Requirement
102
87
  requirements:
103
88
  - - ">="
104
89
  - !ruby/object:Gem::Version
105
90
  version: '0'
106
91
  requirements: []
107
- rubygems_version: 3.4.20
108
- signing_key:
92
+ rubygems_version: 4.0.10
109
93
  specification_version: 4
110
94
  summary: Replace your local git repo with a fresh clone from the remote
111
95
  test_files: []