TicGit-ng 1.0.2.6 → 1.0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,15 +10,28 @@ module TicGitNG
10
10
 
11
11
  def initialize(git_dir, opts = {})
12
12
  @git = Git.open(find_repo(git_dir))
13
- @logger = opts[:logger] || Logger.new(STDOUT)
14
- @last_tickets = []
15
-
16
13
  proj = Ticket.clean_string(@git.dir.path)
17
14
 
18
15
  @tic_dir = opts[:tic_dir] || "~/.#{which_branch?}"
19
16
  @tic_working = opts[:working_directory] || File.expand_path(File.join(@tic_dir, proj, 'working'))
20
17
  @tic_index = opts[:index_file] || File.expand_path(File.join(@tic_dir, proj, 'index'))
21
18
 
19
+ @logger = opts[:logger] || Logger.new(STDOUT)
20
+ @last_tickets = []
21
+
22
+ #expire @tic_index and @tic_working if it mtime is older than git log
23
+ puts "Started"
24
+ if File.exist?(@tic_working)
25
+ puts "Inside"
26
+ cache_mtime=File.mtime(@tic_working)
27
+ gitlog_mtime=git.gblob(which_branch?).log(1).map {|l| l.committer.date }[0]
28
+ #unless (cache_mtime > gitlog_mtime.-(20) and cache_mtime <= gitlog_mtime) or (cache_mtime > gitlog_mtime.+(30) and cache_mtime >= gitlog_mtime)
29
+ if ((cache_mtime.to_i - gitlog_mtime.to_i) > 120) or ((gitlog_mtime.to_i - cache_mtime.to_i) > 120)
30
+ puts "Resetting cache"
31
+ reset_cache unless cache_mtime==gitlog_mtime
32
+ end
33
+ end
34
+
22
35
  # load config file
23
36
  @config_file = File.expand_path(File.join(@tic_dir, proj, 'config.yml'))
24
37
  if File.exists?(config_file)
@@ -346,7 +359,6 @@ module TicGitNG
346
359
  FileUtils.mkdir_p(@tic_working)
347
360
  needs_checkout = true
348
361
  end
349
-
350
362
  needs_checkout = true unless File.file?('.hold')
351
363
 
352
364
  old_current = git.lib.branch_current
@@ -378,5 +390,14 @@ module TicGitNG
378
390
  #If has ~/.ticgit-ng dir, and 'ticgit-ng' branch, and not ~/.ticgit dir and not 'ticgit' branch
379
391
  end
380
392
 
393
+ def reset_cache
394
+ #@state, @tic_index, @tic_working
395
+ FileUtils.rm File.expand_path(@state) rescue nil
396
+ FileUtils.rm File.expand_path(@tic_index) rescue nil
397
+ FileUtils.rm_r File.expand_path(@tic_working) rescue nil
398
+ @state=nil
399
+ FileUtils.mkdir_p File.expand_path(@tic_working)
400
+ end
401
+
381
402
  end
382
403
  end
@@ -1,3 +1,3 @@
1
1
  module TicGitNG
2
- VERSION = '1.0.2.6'
2
+ VERSION = '1.0.2.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TicGit-ng
3
3
  version: !ruby/object:Gem::Version
4
- hash: 91
4
+ hash: 89
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 2
10
- - 6
11
- version: 1.0.2.6
10
+ - 7
11
+ version: 1.0.2.7
12
12
  platform: ruby
13
13
  authors:
14
14
  - Scott Chacon